C# 自定义服务器变量IIS
我正在尝试使用url重写创建自定义服务器变量。 IIS的Url重写生成以下配置项C# 自定义服务器变量IIS,c#,iis,url-rewriting,web-config,request.servervariables,C#,Iis,Url Rewriting,Web Config,Request.servervariables,我正在尝试使用url重写创建自定义服务器变量。 IIS的Url重写生成以下配置项 <rewrite> <rules> <rule name="CName to URL - Rewrite" stopProcessing="true"> <match url=".*" /> <conditions>
<rewrite>
<rules>
<rule name="CName to URL - Rewrite" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www)(.*)\.localfurnco\.de" />
</conditions>
<action type="Rewrite" url="?" appendQueryString="false" />
<serverVariables>
<set name="HTTP_MANUFACTURER" value="{C:1}" />
</serverVariables>
</rule>
</rules>
</rewrite>
但是在遍历服务器变量时,我找不到HTTP\U制造商。
url重写似乎有效,但我无法获取变量
我试图调用地址:test.localfurnco.de/subdir/webservice.asmx?wsdl
C:1在这种情况下应为:“测试”
如有任何建议和建议,我将不胜感激
提前谢谢试了几个小时后,我自己就明白了。 这是最终的规则
<rule name="CName to URL - Rewrite" stopProcessing="false">
<match url=".*" negate="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{SERVER_NAME}" pattern="^(?!www)(.*)\.localfurnco\.de" />
</conditions>
<action type="Rewrite" url="?CustomValue={C:1}" logRewrittenUrl="true" />
<serverVariables>
<set name="HTTP_MANUFACTURER" value="{C:1}" />
</serverVariables>
</rule>
朋友与我分享的另一个选择是:
string value= HttpContext.Current.Request.Params.Get("CustomValue");
正如您所看到的,我重写了url并设置了一个参数,通过模式分配了过滤值
我希望这对其他人有帮助
string value= HttpContext.Current.Request.Params.Get("CustomValue");