I have set a server variable to be available on my IIS server called COUNTRY_PATH
I am doing a Reverse Proxy rewrite from one site to another and need to access this server variable in my proxied site. However it never seems to have a value.
<rule name="Country Codes For DotCom" stopProcessing="true">
<match url="^([A-Z]{2,2})(/)(microsite)(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="\.com$" />
</conditions>
<serverVariables>
<set name="COUNTRY_PATH" value="{R:1}{R:2}{R:3}" />
</serverVariables>
<action type="Rewrite" url="http://internal.example.com/{R:1}{R:2}{R:3}{R:4}" />
</rule>
Are Server Variables available for reverse proxy?
I am using the following code to get the server variable:
string countryPath = HttpContext.Current.Request.ServerVariables["COUNTRY_PATH"]
Can anyone suggest what I am doing wrong?