我有一个大型会员营销网站,在Windows Azure上托管了数百万种产品。对于SEO,我必须提供一个动态创建的sitemap.xml。
public ActionResult SiteMap() { string sitemapUrl = "https://trendley.blob.core.windows.net/sitemap/sitemap.xml"; byte[] bImage = null; using (WebClient wc = new WebClient()) { bImage = wc.DownloadData(sitemapUrl); } return File(bImage, "application/octet-stream"); }
我将以下路由添加到我的RouteConfig中:
routes.MapRoute("Sitemap", "sitemap.xml", new { controller = "Home", action = "Sitemap" });
不幸的是,这没有用。我得到-> HTTP错误404.0-找不到
当我将“ sitemap.xml”更改为sitemapxml(除去扩展名)时,将调用我的控制器方法。已经进行了一些研究并使用了我的web.config,但似乎没有任何效果。
我尝试的第一件事是添加:
第二件事:
有人可以告诉我如何做到这一点。我是否需要为此编写自己的处理程序?
干杯,斯特凡