我的网站同时包含 HTTP 和 HTTPS 页面。
我尝试了以下方法来确保 cookie 的安全:
- Web.config
<httpCookies requireSSL="true" />
使用表单例份验证。 - 强制 cookie 安全于
Application_End
在这两种情况下,页面都不支持 HTTP。我认为上述解决方案仅在所有页面都使用 HTTPS 时才有效。
如何解决这个难题?
最佳答案
将 cookie 设置为“安全”的全部意义在于它仅通过 https 传输; http 页面将不会收到它的副本。来自 Wikipedia :
A secure cookie has the secure attribute enabled and is only used via HTTPS, ensuring that the cookie is always encrypted when transmitting from client to server. This makes the cookie less likely to be exposed to cookie theft via eavesdropping.
如果要使用安全cookie,需要确保所有页面都使用https。
关于c# - ASP.NET 在 HTTP 和 HTTPS 上保护 Cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18016842/