日期:2014-05-17  浏览次数:20469 次

MVC3 当URL为.html(点html)结尾时,就路由不到
本帖最后由 zhvlian9 于 2013-07-15 22:28:26 编辑
IIS 6.0 
MVC3

不带后缀的都能路由到 像www.xxx.com/index/1/
但带了后缀就路由不到了 像 www.xxx.com/index/1.html或www.xxx.com/index/1.action

补充:原先的代码一直可以的,后来重新换了的空间就成上面的样子了。
MVC IIS6 路由

------解决方案--------------------

{controller}/{action}/{id}.action,
new { controller = "Home", action = "Index", id = UrlParameter.Optional }

------解决方案--------------------
路由没有配置好。
参考:
     routes.MapRoute(
             "Default3", // 路由名称
            "{controller}/{action}/{id}-.html", // 带有参数的 URL
             new { action = "Index", id = UrlParameter.Optional },
             new string[] { "PRO.Controllers" }
            );
------解决方案--------------------
你得在IIS中把html后缀映射为由.net框架处理程序来处理,象aspx等后缀一样,否则你再怎么改路由也没用,因为IIS不会把这些文件交给你处理。
------解决方案--------------------
iis无法运行mvc的伪静态路由 解决方案:
在webconfig里的webserver下添加这句话:<modules runAllManagedModulesForAllRequests="true" />