0

Our Server Admin has setup a "Site Binding" in IIS for a website on the server, so that when an end user uses a specific url, it redirects to our site.

I need to be able to determine when one of these redirects has taken place, and then land the end user on a specific page on the website.

Can anyone help?

3
  • How many bindings are there? How many different URLs do you want to redirect to? i.e. do you require a static or dynamic solution. Commented Jun 3, 2014 at 9:25
  • There are 3 bindings, but i only need to act on thsi one particular binding, i think i need a re-write rule, i'm just not sure how. Commented Jun 3, 2014 at 9:26
  • Ok, don't think a web.config rewrite rule will suffice... try using the URLReferrer on the page the binding redirects to (and only that page) and if it matches the binding, redirect to where you want. Or as said below, use the server variables to detect the 'urlreferer' and redirect accordingly. Commented Jun 3, 2014 at 12:30

3 Answers 3

1

Your question says that users are getting redirected to your site, but that's not really how IIS site bindings work. They are more like aliases for a single site. If that is the case, and the site has multiple bindings and you want to redirect based on which binding was used, then yes you would use a rewrite rule in web.config system.webServer section, like so:

    <rewrite>
        <rules>
            <clear />
            <rule name="redirect" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{SERVER_NAME}" pattern="www.binding1.com" />
                </conditions>
                <action type="Redirect" url="http://www.binding2.com/pages/binding1home" />
            </rule>
        </rules>
    </rewrite>
Sign up to request clarification or add additional context in comments.

Comments

0

You can find the binding name in Request.ServerVariables under: "HTTP_HOST" or "SERVER_NAME". If you have access to the server variables? If so you could than redirect to a specific page if the specified binding name is found. (see: MSDN)

Comments

0

Depending on how the redirect is setup you could try and use the UrlReferrer property of the current request:

Request.UrlReferrer

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.