Click here to Skip to main content
15,040,212 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am looking for a simple example for URL Rewriting when a button is clicked in asp.net.

I have searched for long time. But I did not find any answer that I am looking for.

Thanks..

For eg:

I have Products.aspx page where I enter the Category id and on button click it redirects to Category.aspx page and displays the list of products that comes under the given category id.

Usually the redirected URL will be carrying the Category ID http://localhost:3501/URLRewriteConcept/Category.aspx?id=1

But I am in need of URL like this : http://localhost:3501/URLRewriteConcept/ProductCategories and also should be able read the category id and display the products belong to that ID.
Posted
Updated 26-Jun-12 0:15am
v2
Comments
Sandeep Mewara 26-Jun-12 5:25am
   
Why do you want something like this to be on a button click. Elaborating more on what/why would help.
Mylog.25 26-Jun-12 7:43am
   
In all the URL's searched so far I can find the concept is implemented in global.asax. I am just looking for a simple example to implement the concept in ASP.Net button click.

For eg:

I have Products.aspx page where I enter the Category id and on button click it redirects to Category.aspx page and displays the list of products that comes under the given category id.

Usually the redirected URL will be carrying the Category ID http://localhost:3501/URLRewriteConcept/Category.aspx?id=1

But I am in need of URL like this : http://localhost:3501/URLRewriteConcept/ProductCategories and also should be able read the category id and display the products belong to that ID.

Is google broken at your side? What have you tried so far? There are enough articles available about this article on internet.

You must try MSDN First: URL Rewriting in ASP.NET[^]

A good CP Article on same which demonstrates the use of regular expression-based URL Rewriting, similar to mod_rewrite with ASP.NET: URL Rewriting with ASP.NET[^]

Have a look on google[^] & more on CodeProject[^] answers for similar question.
   
Comments
   
Good reply, a 5.
--SA
Prasad_Kulkarni 26-Jun-12 7:27am
   
Thank you SA
Rahul Rajat Singh 26-Jun-12 2:54am
   
Good answer. +5.
Prasad_Kulkarni 26-Jun-12 7:28am
   
Thank you Rahul!
[no name] 26-Jun-12 6:27am
   
Very good
Prasad_Kulkarni 26-Jun-12 7:28am
   
Thank you Mukesh!
[no name] 26-Jun-12 7:39am
   
yoy are welcome :)
Based on your comment, that you want this to see/implement it on button click event: It is not the way how URL Rewriting works. It works at application level. Handling only one request in other way as tried by you is not URL rewriting implementation.
   
Comments
Mylog.25 27-Jun-12 0:13am
   
Thanks..
Sandeep Mewara 27-Jun-12 2:07am
   
Welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900