MVC 路由设置伪静态

Posted 落叶子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MVC 路由设置伪静态相关的知识,希望对你有一定的参考价值。

 public static void RegisterRoutes(RouteCollection routes)
        {
           routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
           routes.MapRoute("Defaults", "{controller}/{id}.html",
           new { controller = "Home", action = "Info", id = UrlParameter.Optional },
           new { controller = @"News|Solutions" },
           new[] { "Web.UI" });
         
          
            routes.MapRoute(
               name: "Default",
               url: "{controller}/{action}/{id}",
               defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
               namespaces: new string[1] { "Web.UI" }
           );
        }

  然后在Web.config 的<system.webServer>节点下添加<modules runAllManagedModulesForAllRequests="true" />

以上是关于MVC 路由设置伪静态的主要内容,如果未能解决你的问题,请参考以下文章