需要更新 IIS web.config 以通过添加 SSL 来保护 cookie。
Web.Config 当前包含以下代码片段。
<configuration>
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
</system.web>
</configuration>
想要更新 system.web 部分,如下所示。
需要修改(假设你会使用Set-WebConfiguration)
<authentication mode="Forms">
to
<authentication mode="Forms" requireSSL="true">
需要添加(假设您将使用 Add-WebConfiguration
<httpCookies httpOnlyCookies="true" />
已成功使用以下内容更新 web.config,
Add-WebConfigurationProperty -pspath "iis:\Sites\FMC" -filter "/appSettings" -name "." -Value @{key='fmcDataContextType';value='SqlRepository.fmcDataContext'}
但似乎无法为此目的获得正确的格式。
For 需要SSL:
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site' -filter "system.web/authentication/forms" -name "requireSSL" -value "True"
for httpOnlyCookies use:
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site' -filter "system.web/httpCookies" -name "httpOnlyCookies" -value "True"
用于添加httpOnlyCookies use:
Add-WebConfigurationProperty //system.web 'MACHINE/WEBROOT/APPHOST/Default Web Site' -Name httpCookies -Value "True"
你必须更换Default Web Site
与您的网站的名称。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)