Skip to content

Instantly share code, notes, and snippets.

@rriifftt
Created October 27, 2015 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rriifftt/083ecbd2f7c852b45d19 to your computer and use it in GitHub Desktop.
Save rriifftt/083ecbd2f7c852b45d19 to your computer and use it in GitHub Desktop.
powershell で X-AspNet-Version ヘッダを削除する ref: http://qiita.com/satoshi_iwashita/items/6751e9b87eae0cf08bba
<httpRuntime enableVersionHeader="false" />
<system.webServer>
<rewrite>
<allowedServerVariables>
<add name="RESPONSE_X-ASPNET-VERSION" />
</allowedServerVariables>
<outboundRules>
<rule name="RESPONSE_X-ASPNET-VERSION">
<match serverVariable="RESPONSE_X-ASPNET-VERSION" pattern=".+" />
<action type="Rewrite" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
# add allowedServerVariables
$asv = Get-WebConfigurationProperty `
-filter "//rewrite/allowedServerVariables/add"`
-name name
if ($asv -eq $null)
{
Add-WebConfigurationProperty `
-Filter "//rewrite/allowedServerVariables" `
-PSPath "IIS:\" `
-Name "Collection" `
-Value @{name="RESPONSE_X-ASPNET-VERSION"}
}
# add rule
$rule = Get-WebConfigurationProperty `
-filter "//rewrite/outboundRules/rule[@name='REMOVE_X-ASPNET-VERSION']/match"`
-name serverVariable
if ($rule -eq $null)
{
Add-WebConfigurationProperty `
-Filter "//rewrite/outboundRules" `
-PSPath "IIS:\" `
-Name "Collection" `
-Value @{name="REMOVE_X-ASPNET-VERSION"}
Set-WebConfiguration `
-Filter "//rewrite/outboundRules/rule[@name='REMOVE_X-ASPNET-VERSION']/match" `
-PSPath "IIS:\" `
-Value @{serverVariable="RESPONSE_X-ASPNET-VERSION";pattern=".+"}
Set-WebConfiguration `
-Filter "//rewrite/outboundRules/rule[@name='REMOVE_X-ASPNET-VERSION']/action" `
-PSPath "IIS:\" `
-Value @{type="Rewrite"}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment