Friday, January 23, 2009

URL Remapping in .Net 2.0

In this article I will walk through a concept for URL Remapping in .Net 2.0

The need for url remapping can arise due to several reasons like
Generating SEO friendly urls
Hiding the actual page or other data from web users.
Control over each and every entry and exits for web requests.
Etc.
.Net 2.0 gives flexibility to define and remap urls in web.config file as well as generating your own Custom URL Remapper HTTP Module.
I will explain the first approach i.e remap urls in web.config in this post and will try to wrap up the second one in my next article with a pretty decent code sample for building Custom URL Remapper HTTP Module.
Remapping URL's in web.config file.
To Map urls .Net provides a section named  urlMappings in web.config file where one can define the collection for their mapped urls.

[sourcecode language='html']


 
  
 



[/sourcecode]

Here whenever the request for Home.aspx will come the .Net engine will search for  urlMappings section in web.config file and server the page that is mapped with it. In the above mention example it will server Default.aspx page.
Limitations: To have more control over the urls, regular expression cannot be used. So it is better to build our own  URL Remapper HTTP Module.
Live World Scenario:
In case of shopping cart with thousands of product categories and catalogs it is very important to make this page SEO Friendly. Though SEO includes several criteria depending on different robots basic idea of URL remains the same. So by using URL Remapping we can generate SEO friendly URLS that robots can easily search.
Like say for example we are having three products categories viz
CellPhones
Computers
DigitalCameras
We can map all the three categories to a single page that servers the purpose of displaying these products based on the product name
So we map all the three to Product.aspx page like shown in the below section.

[sourcecode language='html']


 
  
 
 
 



[/sourcecode]

Now whenever the request for  CellPhones.aspx,  Computers.aspx or DigitalCameras.aspx comes .Net engine will compile Product.aspx page and will server to the requesting client. In Product.aspx page we can extract the name and make calls to database to get all the products related to the given category.

 

To Download code sample Click Here

15 comments:

Ulysses said...

If you are more concerned about function over fashion,
Silent Call introduced the Silent Touch Watch for the vision and hearing-impaired a few years ago.
If money is no object, consider the luxury jewelry watches manufactured by
Chaumet, Chopard and Harry Winston. The Excenter Biretro is a self-winding watch set in an 18-karat gold case surrounded by 181 diamonds and a genuine mother-of-pearl white gold dial.

psychic predictions 2012 presidential race said...

Hello! I'm at work browsing your blog from my new apple iphone! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the superb work!

Rodolfo said...

Its such as you learn my mind! You seem to know so much approximately this, like
you wrote the book in it or something. I think that you can do with a
few percent to force the message home a bit, however instead of
that, this is magnificent blog. A great read.
I'll definitely be back.

http://chelmsfordchurches.net/web/index.php?option=com_jevents&task=day.listevents&year=2011&month=04&day=15&Itemid=0 said...

I quite like reading an article that can make people think.
Also, thank you for allowing for me to comment!

casino cash journey said...

I drop a leave a response when I like a post on a website or I have something to valuable to contribute to the
conversation. Usually it's caused by the passion communicated in the article I browsed. And after this article URL Remapping in .Net 2.0 « Dhaval Upadhyaya. I was moved enough to drop a thought :-) I actually do have a few questions for you if it's
okay. Could it be just me or does it appear like a few of these remarks come across like coming from brain dead folks?
:-P And, if you are posting on additional places, I would like to follow
you. Could you list every one of your public pages like your twitter feed, Facebook page
or linkedin profile?

Bookmark Twitter said...

Superb, what a webpage it is! This webpage gives helpful facts to us, keep it up.

Birmingham Conference Venues said...

It's going to be finish of mine day, except before ending I am reading this impressive paragraph to increase my knowledge.

williamson county divorce court said...

Hey there! This is my first comment here so I just wanted to give
a quick shout out and tell you I truly enjoy reading your posts.
Can you suggest any other blogs/websites/forums that go over the same subjects?
Thanks!

Millie said...

After looking over a few of the articles on your web site,
I seriously appreciate your technique of writing a blog. I saved as a favorite it to my bookmark site list and will be checking back in the near future.
Take a look at my website as well and tell me how you feel.

casino royale said...

My brother suggested I might like this website.
He used to be entirely right. This put up truly
made my day. You can not imagine simply how so much time I
had spent for this info! Thanks!

pa system for band said...

Wow, awesome blog layout! How lengthy have you
ever been running a blog for? you make blogging look easy.
The full glance of your website is wonderful, let alone the content
material!

Gudrun said...

What's up, all is going sound here and ofcourse every one is sharing information, that's genuinely excellent, keep up writing.

Sam said...

Hi i am kavin, its my first occasion to commenting anywhere, when i
read this post i thought i could also create comment due to
this brilliant post.

dentist duncan ok said...

Spot on with this write-up, I honestly think this site needs a lot more attention.

I'll probably be back again to read more, thanks for the information!

SCS Study Guide said...

Piece of writing writing is also a fun, if you be acquainted with then you can write if not it is complicated to write.
SCS Study Guide