mvc 标准的写法 一般是(http://localhost:8149/Home/Index) 路由配置以下:css
有时候需求 如 http://localhost:8149/Home/Index 改成http://localhost:8149/index.html 让其看起来更加像一个静态网站html
//配置首页 伪静态 路由 routes.MapRoute("pc_index", "index.html", new { controller = "Home", action = "Index" });
然而 web
解决方式一(不建议)修改 Web.config 文件 mvc
<system.webServer> <modules runAllManagedModulesForAllRequests="true" > </modules> </system.webServer>
这种方式强烈不建议:
一、这些问题的形式是使全部注册的HTTP模块在每一个请求上运行,而不单单是托管请求(例如.html)。 这意味着模块将永远运行.jpg .gif .css .aspx等
二、浪费资源
三、并具备可能致使错误的全局效应网站
<system.webServer> <modules > <remove name="UrlRoutingModule-4.0" /> <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /> </modules> </system.webServer>
<system.webServer> <handlers> <add name="htmlHandler" verb="GET,HEAD" path="*.html" type="System.Web.StaticFileHandler"/> </handlers> </system.webServer>