Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (
-   ASP (
-   -   How is a route table created in ASP.NET MVC? (

chinmay.sahoo 01-06-2017 03:45 AM

How is a route table created in ASP.NET MVC?
When an MVC application first starts, the Application_Start() method in global.asax is called. This method calls the RegisterRoutes() method. The RegisterRoutes() method creates the route table for the MVC application.

Fat Cutter Powder | Asthi jivak | Fat Cutter

sonvi.belani 03-16-2017 12:16 AM


The RouteTable is a class that stores the URL routes for your application.A RouteCollection provides a collection of route information to be used when mapping a URI to a controller action.The RouteTable contains a property called Routes that will return a RouteCollection. The RouteTable uses a RouteCollection in order to store all the URL routing information it needs to accurately direct URI's to the correct controller action.In your global.asax you will register the routes that will map to various controller actions.

protected void Application_Start()
{RegisterRoutes(RouteTable.Routes); }

Then a route will be added to the RouteCollection in the following way:///
/// Registers the routes used by the application. ///
/// Routes to register.

public static void RegisterRoutes(RouteCollection routes)
routes.MapRoute("Error", "Error", new { controller = "Error", action = "Error" });
This shows how the actual route information is stored in a RouteCollection, which in turn is referenced via the RouteTable.


All times are GMT -7. The time now is 01:02 AM.

Powered by vBulletin Copyright © 2013 vBulletin Solutions, Inc.