In Area VIPUsers I have controller ProfileController and other controllers.
If I want every method in ProfileController to have parameter (id) and every method in other controllers to have parameter (userid and id) how would I map it?
Would it be
context.MapRoute(
"ProfileMapping",
"VIPUsers/Profile/{action}/{id}",
new {controller="ManageUsers", id=""}
);
and then map a default one for all the controllers?
context.MapRoute(
"Default",
"VIPUsers/{controller}/{action}/{userId}/{id}",
new {action="Index", userId="", id = ""}
);
and...that's it? I see it's working but then it's weird...
If I go to a page on ProfileController and give it two parameters after {action}
(VIPUsers/Profile/SomeAction/4/4/), it'd use the second mapped route. I开发者_如何学Pythons that correct?
thanks
and if I want the url to always require a UserId, how do I specify that?
The behavior you are seeing is correct. You will want to implement some route constraints to further narrow things down:
http://www.asp.net/learn/mvc/tutorial-24-cs.aspx
精彩评论