zoukankan      html  css  js  c++  java
  • ASP.NET MVC如何设置路由启动

    在Global.asax.cs里可见如下类似设置:
    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            //路由忽略
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "DevList",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Data", action = "List", id = UrlParameter.Optional }
            );
            
            //默认启动name为Default的路由,有多个MapRoute时,建议将Default项放在最后
            routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Login", id = UrlParameter.Optional }
                );
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterRoutes(RouteTable.Routes);
        }
  • 相关阅读:
    MyBatis入门基础
    复制复杂链表
    二叉树中和为某一值的所有路径
    树的层次遍历
    Statement, PreparedStatement和CallableStatement的区别
    JSP有哪些动作?
    latex 输入矩阵
    Struts简单入门实例
    在Eclipse里面配置Struts2
    Windows使用Github
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/2816507.html
Copyright © 2011-2022 走看看