zoukankan      html  css  js  c++  java
  • MVC伪静态路由简单搭配

      public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
                routes.MapRoute(
                    "Root",
                    "",
                    new {controller = "Home", action = "Index", id = UrlParameter.Optional},
                    namespaces: new string[] { "Jxrlzy.Controllers" }
                    ); //根目录匹配
                
                routes.MapRoute(
                    "Controller1Html", // action伪静态    
                    "{controller}.html", // 带有参数的 URL    
                    new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // 参数默认值
                    namespaces: new string[] { "Jxrlzy.Controllers" }
                    );
                routes.MapRoute(
                    "Action1Html", // action伪静态    
                    "{controller}/{action}.html", // 带有参数的 URL    
                    new {controller = "Home", action = "Index", id = UrlParameter.Optional}, // 参数默认值
                    namespaces: new string[] {"Jxrlzy.Controllers"}
                    );
                routes.MapRoute(
                    "Action", // action伪静态    
                    "{controller}/{action}", // 带有参数的 URL    
                    new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // 参数默认值
                    namespaces: new string[] { "Jxrlzy.Controllers" }
                    );
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}.html",
                    defaults: new {controller = "Home", action = "Index", id = UrlParameter.Optional},
                    namespaces: new string[] {"Jxrlzy.Controllers"}
                    );
                ModelBinders.Binders.Add(typeof(JObject), new JObjectModelBinder());
            }
  • 相关阅读:
    老鸟的Python新手教程
    vs2010经常使用快捷键
    SQL基础--> 约束(CONSTRAINT)
    哈哈,做题了
    【网络协议】TCP中的四大定时器
    JAVA反射机制
    JUnit入门
    怎样将程序猿写出来的程序打包成安装包(最简单的)
    事件传递机制总结
    理解class.forName()
  • 原文地址:https://www.cnblogs.com/fanying/p/10918800.html
Copyright © 2011-2022 走看看