Friday, June 15, 2007

ASP.NET 2.0 - URL Mapping

ASP.NET 2.0 provides features supporting "vanity url's" or "friendly url's". These are useful when you want to distribute simple url's to customers.

Say for instance you have an online store, offering a new product to a segment of customers. The path to the catalog item is

    http://AcmeCorp.com/store/catalog.aspx?productid=TY3466a&customerid=143044&branch=south
But you'd like to distribute a simpler url:

    http://AcmeCorp.com/store/MultiVitamins.aspx
URL Mapping makes this possible. The following is a much simpler example. Note that it just happens to use the location appSettings overrides described in an earlier blog.
The highlighted section specifies the url mapping. The vanity url's (Diablo_Config.aspx and Diablo_Config.aspx?loc=test) are actually just as complicated as the actual paths (testconfig.aspx and test/testconfig.aspx), but it illustrates what's possible. The following screenshots illustrate what the "customer" sees:


The aspx page that outputs the appSettings is simply copied to the application root and /Test folder for illustrative purposes. If you're interested in aspx (not code-behind) that references app settings, see the following link.

6 comments:

Anonymous said...

What namespace is required to use the ConfigurationManager ?

Diablo said...

The System.Configuration namespace. In VS.NET 2005, you have to add the System.Configuration.dll as a reference.

Anonymous said...

How about I don't add a reference but only mention at the top of my .cs file as

using System.Configuration

Will it work ?

Thanks,

Diablo said...

In my version of VS.NET 2005, it will not work :).

sex shop said...

It cannot have effect in actual fact, that is exactly what I think.

price per head said...

Great site!!! this information really helped me