一.配置文件web.config添加一下設置
<system.webServer> <modules runAllManagedModulesForAllRequests="true" /> </system.webServer>
二.RouteConfig.cs設置
routes.MapRoute( "Login", "Login.html", new { controller = "Home", action = "Login" } ); routes.MapRoute( "Index", "index.html", new { controller = "Home", action = "Index" } ); routes.MapRoute( "Default", "{controller}/{action}.html", new { controller = "Home", action = "Index"} );
三.上面設置好后基本上已經完成了,但是運行時發現首頁不對,這個時候需要一下設置
在Global.asax文件里設置首頁
//把首頁設置為重定向后的index.html地址 protected void Application_BeginRequest(object sender, EventArgs e) { if (Context.Request.FilePath == "/") Context.RewritePath("index.html"); }