can I have domain.com/action/id as well as domain.com/controller/action?
how would I register these in the route-table?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Is ID always guaranteed to be a number? If yes, then you could use RouteConstraints:
The IDConstraint class looks like this:
Basically what is happening is that you have two identical routes here – two parameters, so it’s ambigous. Route Constraints are applied to parameters to see if they match.
So:
If ID is not guaranteed to be a number, then you have the problem to resolve the ambiguity. The only solution I am aware of is hardcoding the routes where {action}/{id} applies, which may not be possible always.