Routing In MVC:
ASP.Net Routing is setup in two places:
1. In Web.config file. There are 4 sections in configuration file that are relevant to routing configuration:
System.web.httpModules1. In Web.config file. There are 4 sections in configuration file that are relevant to routing configuration:
System.web.httpHandlers
System.webserver.modules
System.webserver.handlers
2. In Global.asax, is a specific file that contains event handlers for ASP.Net application lifecycle events. The Route table is created during the Application_Start event as follows:
2. In Global.asax, is a specific file that contains event handlers for ASP.Net application lifecycle events. The Route table is created during the Application_Start event as follows:
Protected void
Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
When an MVC
application starts, the Application_Start() method is called. This in turn
calls the RegisterRoutes() method, this method creates the route table.
The default route table
contains a single route named as Default. The Default route maps the first
segment of URL to controller, second to controller action, third to parameters.
Consider user enters
the URL: …/Home/Index/8
Controller = Home
Action = Index
Parameters = 8