Wednesday 7 October 2015

Routing


The Routing Engine

There is a handler called Application_Start in the Global.asax.cs file for this purpose, the Application_Start event handler calls the static method RegisterRoutes() in the RouteConfig  class located in the App_Start folder.
The method accepts the existing routes table as a parameter so routes can be added to it.

It Includes two default routes so that the project will run. 
  • The first route instructs the routing engine to ignore requests for .axd resources such as  ScriptResource.axd and WebResource.axd. These resources don’t physically exist as files in    the application; rather, they are HttpModules that load special content (such as images, scripts,  CSS, etc.) that are embedded in DLL files so that they can be sent to the browser as part of the  response.
  •  The second route is used to map requests to controllers and action methods

Routing helps you to define user friendly URL structure and map those URL structure to the controller

The route mapping code is written in the “global.asax” file.

eg:











No comments:

Post a Comment