2010-03-29 81 views
0

在区域VIPUsers我有控制器ProfileController和其他控制器。在ASP.NET MVC中映射路由和参数

如果我想在每ProfileController可方法有参数(ID) 及其他控制器的每一个方法有参数(用户名和ID) 我将如何映射它?

难道是

context.MapRoute(
    "ProfileMapping", 
    "VIPUsers/Profile/{action}/{id}", 
    new {controller="ManageUsers", id=""} 
); 

然后映射所有控制器默认吗?

context.MapRoute(
    "Default", 
    "VIPUsers/{controller}/{action}/{userId}/{id}", 
    new {action="Index", userId="", id = ""} 
); 

and ...就是这样吗?我看到它的工作,但它很奇怪...

如果我去ProfileController上的一个页面,给它两个参数{action}(VIPUsers/Profile/SomeAction/4/4 /)之后,它会使用第二个映射路线。那是对的吗?

感谢

,如果我想要的网址总是需要一个用户ID,我怎么指定?

回答