一.配置文件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");
        }

 

相关文章: