Pie*_*one 1 asp.net azure url-rewrite-module azure-web-sites
我想在Azure网站上使用IIS URL重写模块从Web.config设置一个请求标头(确切地说是HTTP_HOST).基本上我想在我的网站的Web.config中有这样的东西:
<system.webServer>
<rules>
<clear />
<rule name="My rule" enabled="true">
<match url=".*" />
<serverVariables>
<set name="HTTP_HOST" value="my value" />
</serverVariables>
<action type="None" />
</rule>
Run Code Online (Sandbox Code Playgroud)
这会导致不允许设置HTTP_HOST的错误.这是正常的,对于标准IIS,下一步是将HTTP_HOST <allowedServerVariables>直接或通过AppCmd 添加到applicationhost.config 的元素.但是,我无法找到任何能够以某种方式访问此配置的提示.
是否有可能以某种方式修改apphost配置,或以其他方式添加允许的服务器变量?
可以通过应用xdt转换来更改Azure的ApplicationHost.config.
将文件上传到/ site并重新启动您的站点以使更改生效:
ApplicationHost.xdt
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<rewrite>
<allowedServerVariables>
<add name="HTTP_HOST" xdt:Transform="Insert" />
</allowedServerVariables>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
也可以看看:
| 归档时间: |
|
| 查看次数: |
1374 次 |
| 最近记录: |