if possible then please provide me code for implementing url routing. suppose i have two url in my page like
first one
http://www.mysite.com/101/category.aspx
so i want that when user click on the above url then request should goes like
http://www.mysite.com/category.aspx?id=101 but
http://www.mysite.com/101/category.aspx this url should show in the addressba.
when any user will directly type url like http://www.mysite.com/category.aspx?id=101 then no routing will happen rather above url should process and
http://www.mysite.com/category.aspx?id=101 this url should show in the addressbar.
second one
http://www.mysite.com/audi/product.aspx
so i want that when user click on the above url then request should goes like
http://www.mysite.com/product.aspx?cat=audi but
http://www.mysite.com/audi/product.aspx this url should show in the addressbar.
when any user will directly type url like http://www.mysite.com/product.aspx?cat=audi then no routing will happen rather above url should process and
http://www.mysite.com/product.aspx?cat=audi this url should show in the addressbar.
i have never work with url routing….so please guide me in terms of coding. thanks
In ASP.NET using the IIS7 rewrite module you would use something like this:
Updated as realised you can’t pass routing variables as
querystringwithMapPageRouteas I originally showed. In fact things get tricky if you want to do this. There’s 2 options I can think of.Option 1)
Use the following route.
Then use the following code in your
category.aspxinstead ofquerystringto extract the category value.Option 2)
This involves creating custom handler to rewrite the
RouteDatainto thequerystringwhen the path is rewritten.This can be registered as follows.