MVC定义路由

标准路由配置
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Alert", action = "Index", id = UrlParameter.Optional }
            );
修改路由参数

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

       routes.MapRoute(
               name: "FontDetail",
               url: "alert/Index/{fontid}",
               defaults: new { controller = "alert", action = "Index", fontid = UrlParameter.Optional }
           );
路由制定页面

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //实际指向配置
            routes.MapRoute(
"DiskFile", "alert/index.cshtml", new { Controller = "alert", Action = "Index",  }
);

            //标准配置
            routes.MapRoute(
   "MyRoute", "{Controller}/{Action}/{id}/{*Catchall}",new {Controller="Home",Action="Index",Id=UrlParameter.Optional }
);

 

posted @ 2016-01-21 20:58  逍遥帝君  阅读(314)  评论(0编辑  收藏  举报