Virtual Classes Logo          Virtual Classes
    Read Anytime,Anywhere

Routing in MVC

Routing in MVC is a pattern matching mechanism.When browser makes a request of a MVC application. then URL Routing module of MVC first get the requested URL and check if these is any matching pattern is written in RouteConfig.cs file. RouteConfig class has RegisteRoutes method which has all the pattern specified to handle the request. If any matching pattern is found then request will be processed according to the matched pattern.
Below example shows registering of URL pattern.

MVC Routing

You can add many route according to your requirement , how you want to process your request. But if URL Routing module finds a matching pattern then it does not look for other matching pattern available/registered in RouteConfig.cs So write your generic pattern at the last and specific pattern at the first.