Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 自定义服务器变量IIS_C#_Iis_Url Rewriting_Web Config_Request.servervariables - Fatal编程技术网

C# 自定义服务器变量IIS

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>

我正在尝试使用url重写创建自定义服务器变量。 IIS的Url重写生成以下配置项

    <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");