【发布时间】:2013-12-11 22:04:37
【问题描述】:
我有一个大型联属网络营销网站,在 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,但似乎没有任何效果。
我尝试的第一件事是添加:
<modules runAllManagedModulesForAllRequests="true" />
第二件事:
<add
name="AdfsMetadata"
path="sitemap.xml"
verb="GET"
type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0" />
谁能告诉我如何完成这个。 我必须为此编写自己的处理程序吗?
干杯, 斯蒂芬
【问题讨论】:
-
最后我发现我编辑了错误的 web.config :(