Routing is a great feature of MVC, it provides a REST based URL that is very easy to remember and improves page ranking in search engines.
This article is not an introduction to Routing in MVC, but we will learn a few features of routing and by implementing them we can develop a very flexible and user-friendly application. So, let's start without wasting valuable time.
Add constraint to URL
This is very necessary for when we want to add a specific constraint to our URL. Say, for example we want a URL.
So, we want to set some constraint string after our host name. Fine, let's see how to implement it.
It's very simple to implement, just open the RouteConfig.cs file and you will find the routing definition in that. And modify the routing entry as in the following. We will see that we have added “abc” before.
Controller name, now when we browse we need to specify the string in the URL, as in the following: