MVC的路由设置【转】

2020-11-15 19:40

阅读:1085

标签:com   http   blog   style   class   div   img   code   java   c   log   

转,MVC的路由设置。

后端获取路由里面action的参数,函数需要设置相同的参数名称才行。

soscw.com,搜素材
 routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { action = "Index", id = "0" },
                new { controller = @"^\w+", action = @"^\w+", id = @"^\d+" });

            // Archive/2008-05-07
            routes.MapRoute(
                "BlogArchive",
                "Archive/{date}",
                new { controller = "Blog", action = "Archive" },
                new { date = @"^\d{4}-\d{2}-\d{2}" });

            // Car/bmw.abc
            routes.MapRoute(
                "Car",
                "Car/{make}.{model}",
                new { controller = "Car", action = "Index" },
                new { make = @"(acural|bmw)" });

            //必须是提交post url直接回车是get
            routes.MapRoute(
                "Book",
                "Book/Add/{name}",
                new { controller = "Book", action = "Add" },
                new { httpMethod = "POST" });

            //后面所有东西都捕获
            routes.MapRoute(
                "CatchIt",
                "Product/{*values}",
                new { controller = "Product", action = "Index" });
soscw.com,搜素材

 

MVC的路由设置【转】,搜素材,soscw.com

MVC的路由设置【转】

标签:com   http   blog   style   class   div   img   code   java   c   log   

原文地址:http://www.cnblogs.com/ringwang/p/3699158.html


评论


亲,登录后才可以留言!