URL Rewriting with Parameters and Postbacks

Posted on 2011-10-21
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
    LVL 33

    Expert Comment

    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

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

    Accepted Solution

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    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…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now