0

This is my rule set up in web.config:

   <rule name="RedirectPopups" stopProcessing="true">
              <match url="^webforms/visitor/popup/*" />
              <conditions>
                <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                <add input="{QUERY_STRING}" pattern="^([^=&amp;]+)=([^=&amp;]+)$" />
              </conditions>
              <action type="Redirect" url="jwelery/INEEDTHEPAGEVARIABLEHERE/{C:1}/{C:2}" appendQueryString="false" redirectType="Permanent" />
            </rule>

Basically I have my popups in webforms\visitor\popup. I want to write a rule that when any page is request within this popup directory. It gets redirected to some custom url.

For Eg.

If user requests webforms/visitor/popup/HelloWorld.aspx?a=1

He should be redirected to jwelery/HelloWorld/a/1

I just need the solution for what should I write in "INEEDTHEPAGEVARIABLEHERE" in Redirect action. Is there any special variable that I can use? I am using IIS7

Thanks.

2 Answers 2

2

Why don't you use

<match url="^webforms/visitor/popup/([a-zA-Z0-9]+).aspx\?([a-zA-Z0-9]+)=([a-zA-Z0-9]+)$" />
<action type="Rewrite" url="jwelery/{R:1}/{R:2}/{R:3}" />

?

Sign up to request clarification or add additional context in comments.

3 Comments

wow this works nicely! Thanks. But can you tell me what is the difference between {R:1} and {C:1} and what exactly are they? Any links or if you can explain then also I will be very grateful.
{R:n} are back-references to rule patterns, {C:n} to condition patterns. You correctly referes to your QueryString pattern using {C:1}. A nice overview can be found here: learn.iis.net/page.aspx/465/…
Thanks Olaf. You have cleared one of my doubts that I had in mind since months.
0

To answer your original question, you could use UrlRouting.
( http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.