Wednesday, January 14, 2009

Multiple Querystring for Url Rewriting

How to Handle Multiple Querystring for Url Rewriting in

Please go through my earlier article on Url Rewriting.
@Update to my earlier article on Simplest Way to write Url Rewriting

If you have gone through my earlier article

<rewrite url="~/Article/(.+)-(.+)-(.+).aspx" to="~/DynamicPage.aspx?MyTitleId=$2&amp;CategoryId=$3"/>

In Web.Config file you can handle special character by replacing it with its code.
Example in our case we have replace & with &amp;

After making changes to web.config file you need to pass third argument as category Id, and that its.  Your code is ready to handle multiple querystring argument.


Praveen said...


Thank you for posting the solution on how to handle Multiple Querystring for Url Rewriting in Very Effective.


Anonymous said...

What if the same page can get just 1 or can get 2 querystrings.

How should the rule be handled ?


Thanks in advance

DotNetGuts said...

You need to check that in Page Load Event whether you received a Single Querystring or Multiple Querystring. And based on that you need to perform the logic.

Anonymous said...

Thanks for your answer.

Can i add any rule dynamically ?

DotNetGuts said...


Could you please explain more, what do you mean by dynamic rule, in this context.

rosebabu said...


can you please provide some idea to write a rewrite rule for the following....



first time i'm accessing the page with two query string, then in the same page i'm sorting so i need to pass 4 querystring.

i could rewrite the url for 1. rewrite came.

sameway i wrote for 2, but the rule taken is 1'st rule.

please provide some idea. thanks in advance.

DotNetGuts said...

Its a Problem, while dealing with Urlrewriter, the rule are been mapped 1 to 1, and so you cannot map same rule for same page multiple times.

Jony Shah said...

Thanks for your help.
At last i have solved my problems.
now i am going to do URL rewrite with multiple Query stirng.

But my problem is :
As i m passing QueryString like this :


and the page on which i m taking the query string i want both "zztest" and also "z123c".

right now i m getting only "z123c".

what to do? how i can get both?
plz reply

Imranonline said...

I have a problem in

i have a domain name where i have used following wrirete urls

but when i use this rule it gives me error like

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

how to fix it wats the problem????

soujanya said...


I have problem with the updated panel in my project, when am using the rewrite url.

I am using URL rewriting - This is what I think is causing the problem
The error will occur whenever I choose a selection for a SECOND time. This means that I could select a value from the first dropdown list and get the same error.

soujanya said...


I have some problem with url rewrite.
Am using the update panels in my project.
Am getting request manager server error exception. Unknown error occurred while processing the request on the server.the status code returns from the server was 404.

I am using URL rewriting - This is what I think is causing the problem
The error will occur whenever I choose a selection for a SECOND time. This means that I could select a value from the first drop down box and get the same error (so it is happening on the second postback.).

Unknown said...

Thank you but I have one question

How can I get the string value after rewriting the url


Most Recent Post

Subscribe Blog via Email

Enter your email address:

Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape