How to set up your web forms application to support Url Routing

Url Routing is a feature of the .Net Framework Version 3.5 SP1 that lets you set up rules that determine which "web page" (resource) will be returned when a particular Url is requested of your web application.

Dot Net Dash leverages Url Routing to implement the REST API which provides server-side connectivity to the Silverlight client component.

If yours is an MVC application, you generally don't have to do anything to support Url Routing since the MVC "New Project" template will have already added the necessary stuff to your web.config file.

With an existing WebForms application, however, you need to add an entry to your web.config file as shown here.

UrlRoutingModule entry in web.config

IIS 6 or IIS 7 Classic Managed Pipeline Mode

As illustrated above, we are adding the UrlRoutingModule to the httpModules element of "system.web". If you are running on the Asp.Net Development Server (from Visual Studio), IIS 6, or IIS7 in Classic mode, you will add the module as shown above (under system.web.) For your convenience, you can copy/paste the text below:

<add ="UrlRoutingModule" ="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

IIS 7 Integrated Managed Pipeline Mode

If you are running on IIS 7 in Integrated Managed Pipeline Mode, you will add the same UrlRoutingModule entry but to the system.webServer instead of the system.web section of your web.config file. In addition, you'll add the UrlRoutingHandler element as shown below.

UrlRoutingModule entry for Integrated Managed Pipeline mode in web.config

Notice that we added the "remove" element just before adding UrlRoutingModule. While this is not required, it is a good idea to avoid problems under future versions of the .Net Framework. For more information on running under IIS 7, check out the article on running on IIS 7 under Integrated Managed Pipeline Mode.

Quick Links

Free download
Asp.Net Admin Tools
Asp.Net Membership and Roles Administration tool

Did you know?

Dot Net Dash gives you instant management of your Asp.Net web applications.