[Last Call] Learn how to a build a cloud-first strategyRegister Now


URL Rewriting with Parameters and Postbacks

Posted on 2011-10-21
Medium Priority
Last Modified: 2012-05-12
Hi all,
We have basic rewriting in place to help us turn URL parameters into friendly URLs as follows:

                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^([^/]+)/([^/]+)/?$" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <action type="Rewrite" url="default.aspx?id={R:1}&amp;name={R:2}" />

Open in new window

With this, our initial url of ~/10/example  works fine.  The trouble is, when we postback, the parameters are again added to the url and this is causing us problems.  And the URL continues to grow with each postback.  Here are the results after the first 3 postbacks (in order):


Can anyone help identfy the correct url pattern to keep this from happening?

Thanks in advance,
Question by:Webbo_1980
  • 2
LVL 33

Expert Comment

ID: 37009342
I'd check your regex, it would seem it's grabbing querystring params, or is it possible there is another rewrite rule active?

Author Comment

ID: 37011008
Thanks raterus but there no other rewrites so any ideas what wrong the regex?
LVL 33

Accepted Solution

raterus earned 2000 total points
ID: 37014754
Just looking at what you have compared to other examples, I'd try not matching the end of the string "?$", something like this.  I don't see why they would based on your expressions, but + is a greedy wildcard character, and could possibly be matching more than you think.  Try this and let me know what happens.


Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Integration Management Part 2
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question