【发布时间】:2015-05-27 12:36:04
【问题描述】:
大家好,我的控制器中有一个 aciton,它为我的站点生成站点地图,这里的问题是第一次当文件不存在时,请求转到操作 但是一旦生成文件,就会在站点中放置一个静态文件,之后当我点击 URL 时,请求不会发送到控制器,是否有解决此问题的方法
Below is the URL
http://localhost:1234/sitemap.xml
Below is the code am using
[HttpGet, ActionName("sitemap")]
public ActionResult sitemap()
{
//will get the sitemap content here and will generate the sitemap
var sitemapFile = "~/sitemap.xml";
return File(sitemapFile, "text/xml");
}
每次我点击 URL 时,它都应该执行操作并重新生成文件,但这在这里不起作用,任何人都可以帮助我
【问题讨论】:
-
@SHammelburg 是的,可以,但我希望它以这种方式工作,因为我们必须将其提交给带有 sitemap.xml 扩展名的谷歌机器人,这就是我必须编写自定义路线的原因
标签: c# asp.net-mvc-5 asp.net-mvc-routing