Tuesday, January 19, 2010

Routing - .net

Routing is a technique which enables us to use a descriptive, search engine and human friendly URL’s for ASP.Net application to access a resource.

namespace: System.Web.Routing - .Netframework 3.5 SP1

Initially, the ASP.Net routing engine is packed with the new ASP.Net MVC framework.

In order to provide routing in asp.net application, we need to first define routes and routing handler.

What is a Route?

A route is a format or pattern of URL we define for application. The route can have placeholders and constant values. The place holders will be replaced with the values that we supply in the URL during processing.

For example,

{controller}/{action}/{Category} -- /products/list/cars or /product/list/phones

Articles/{action}/{Category} -- /Articles/list/jQuery, /Articles/edit/jQuery


A Route is processed and resolved to a virtual path by a route handler. Once we defined our routes, we need to define our route hander to handle the request that follows the route pattern.

What is a RouteHandler?


A RouteHandler is an object that returns the instance of the actual ASP.NET page or HTTP Handler to complete the processing for the URL requested. A RouteHandler class should inherit the System.Web.Routing.IRouteHandler interface and implement GetHttpHandler() method.

No comments: