Question

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?

Was it helpful?

Solution

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>

OTHER TIPS

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)

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

Request.UrlReferrer
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top