Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   ASP (http://siteownersforums.com/forumdisplay.php?f=11)
-   -   How is a route table created in ASP.NET MVC? (http://siteownersforums.com/showthread.php?t=188213)

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

Hi,

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.

Thanks


All times are GMT -7. The time now is 03:07 AM.


Powered by vBulletin Copyright © 2013 vBulletin Solutions, Inc.