MVC: URLs with Multiple IDs

Please see my other MVC articles.

Update Routing to Handle Multiple ID URLs

In this article, I’ll demonstrate how to use multiple values in a URL without the use of QueryString variables.

In the RouteConfig class, map a new route as follows.

Note: I specified a controller as this URL will only be used for this controller, and instead of the usual generic “id” name, I specific unique names for each as I wanted my controller’s action code to be intuitive.

Now in my controller’s action, I can not only receive multiple values, but with specific names.

Note: Ensure the parameter names and order match that of the new mapped route.