mvc,首页静态页,无静态页走路由,如何设置?

在protected void Application_BeginRequest(Object sender, EventArgs e)增加
if (Context.Request.FilePath == "/") Context.RewritePath("index.html");

在路由上再用上你的这个路由规则:routes.MapRoute(
                "html", // Route name
                "{action}.html", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                , new[] { "aWeb.Controllers" }//默认命名空间
            );
在访问www.test.com时有index.html就是index.html,没有时就自动路由规则去了

posted on 2015-10-27 17:37  cchliang  阅读(411)  评论(0)    收藏  举报

导航