I want to create a route like
//Widgets/PerformanceTable/['best' or 'worst' to sort by performance of an investment]
where either ‘best’ or ‘worst’ are required.
Can somebody show me a good way to do this?
Thanks
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.
I’m going to make the assumption that your controller action has the following signature:
In which case the following route will work for you:
If no order is given, a default order of ‘best’ is passed into the controller.
The final parameter of MapRoute is a regular expression defining the possible values for the order parameter (in this case ‘best’ and ‘worst’). If any other value is given, then the route won’t match.