ASP.NET MVC5路由实践RouteConfig

RouteConfig.cs

复制代码
public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
     //如请求http://localhost:50836/test,由ZJ.MVC5.Platform.Controllers.TestController.cs 响应请求 
        routes.MapRoute(
            name: "Default2",
            url: "test/{action}",
            defaults: new { controller = "Test", action = "Index", id = UrlParameter.Optional },
            namespaces: new string[] { "ZJ.MVC5.Platform.Controllers" }
        );

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
        ////defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        //defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional },
        ////defaults: new { controller = "Test", action = "ShopPic", id = UrlParameter.Optional },
        //namespaces: new string[] { "ZJ.MVC5.Platform.Areas.Movie" } //影片管理
        //).DataTokens.Add("Area", "Movie");

        defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional },
        namespaces: new string[] { "ZJ.MVC5.Platform.Areas.QuestionBank" }
        ).DataTokens.Add("Area", "QuestionBank");
    }
}
复制代码

 

posted @   轴轴  阅读(317)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示