Icemanind
Icemanind

Reputation: 48696

Creating friendlier URLs in an ASP.NET WebForm application

I have an ASP.NET WebForms application. What I am trying to do is create dynamic friendly URLs using RewritePath. What I want to be able to do is grab the subdomain of the URL coming in, check a table in my database called Domains and then depending on the subdomain, rewrite the url adding a query string of ?id=1 or whatever the id is.

In addition, I would like the path to determine the page to load. So for example:

http://www.mysite.com should go to                --> http://www.mysite.com/Default.aspx
http://dog.mysite.com should go to                --> http://www.mysite.com/MainPage.aspx?id=1
http://cat.mysite.com should go to                --> http://www.mysite.com/MainPage.aspx?id=2
http://cat.mysite.com?p=15 should go to           --> http://www.mysite.com/MainPage.aspx?id=2&p=15
http://cat.mysite.com/OtherPage should go to      --> http://www.mysite.com/OtherPage.aspx?id=2
http://cat.mysite.com/OtherPage?p=15 should go to --> http://www.mysite.com/OtherPage.aspx?id=2&p=15

Hopefully the examples give you the idea that I am looking for. I would prefer to be able to do this from the global.asax file because I do not have access to the IIS web server machine to be able to install some server-side module for URL rewriting.

Thanks in advance for the help

Upvotes: 0

Views: 247

Answers (1)

Mahdi Tahsildari
Mahdi Tahsildari

Reputation: 13582

Read this blog of ScuttGu it talks about url renaming in details.

Upvotes: 1

Related Questions