0

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. Is that correct?

thanks

and if I want the url to always require a UserId, how do I specify that?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.