开发者

Asp.net Mvc Routing problem

开发者 https://www.devze.com 2023-01-07 15:33 出处:网络
alt text http://img243.imageshack.us/img243/3249/50263677.jpg Global.asax Code: routes.MapRoute( \"Default\", // Route name

alt text http://img243.imageshack.us/img243/3249/50263677.jpg

Global.asax Code:

routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "article", action = "article", id = UrlParameter.Optional } // Par开发者_StackOverflow中文版ameter defaults
);

I want to use url routing like this:

www.domainname.com/Article/123/bla_article

how can ı do this ?

This work: www.domainname.com/article/article/123

this not work: www.domainname.com/article/123

please Help


Like this:

routes.MapRoute( 
    "Article", 
    "Article/{id}", 
    new { controller = "article", action = "article", id = UrlParameter.Optional } 
);


routes.MapRoute(
"Default", // Route name
"article/{action}/{id}", // URL with parameters
new { action = "article", id = UrlParameter.Optional } // Parameter defaults
);
0

精彩评论

暂无评论...
验证码 换一张
取 消