[英]Powershell: Updating IIS web.config
Needing to update IIS web.config to secure cookies by adding SSL. 需要通过添加SSL更新IIS web.config以保护cookie。
Web.Config currently contains the following snippet. Web.Config当前包含以下代码段。
<configuration>
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
</system.web>
</configuration>
Wanting to update system.web section as follows. 想要更新system.web部分,如下所示。
Need to modify (Assume you would use Set-WebConfiguration) 需要修改(假设您将使用Set-WebConfiguration)
<authentication mode="Forms">
to
<authentication mode="Forms" requireSSL="true">
Need to add (Assume you would use Add-WebConfiguration 需要添加(假设您将使用Add-WebConfiguration
<httpCookies httpOnlyCookies="true" />
Have used the following successfully to update web.config, 已成功使用以下内容更新了web.config,
Add-WebConfigurationProperty -pspath "iis:\Sites\FMC" -filter "/appSettings" -name "." -Value @{key='fmcDataContextType';value='SqlRepository.fmcDataContext'}
But can't seem to get the right format for this purpose. 但是似乎无法为此目的获得正确的格式。
For requireSSL : 对于requireSSL :
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site' -filter "system.web/authentication/forms" -name "requireSSL" -value "True"
for httpOnlyCookies use: 供httpOnlyCookies使用:
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site' -filter "system.web/httpCookies" -name "httpOnlyCookies" -value "True"
for adding httpOnlyCookies use: 用于添加httpOnlyCookies的方法是:
Add-WebConfigurationProperty //system.web 'MACHINE/WEBROOT/APPHOST/Default Web Site' -Name httpCookies -Value "True"
you have to replace Default Web Site
with the name of your site. 您必须将
Default Web Site
替换为您的网站名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.