c# - ASP.NET 在 HTTP 和 HTTPS 上保护 Cookie

标签 c# javascript asp.net security cookies

我的网站同时包含 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/

相关文章:

c# - 远程服务器返回错误 : (401) Unauthorized

javascript - 如何在 AngularJS 中将 Controller 绑定(bind)到动态生成的 HTML 页面?

jquery - 在我的网页上显示动态数据(进度)

asp.net - 在中继器 asp.net 中调用函数

c# - 在 gridview 中使用 PAGING 为 FILTER 实现正确逻辑的方法

c# - Skip 的性能(以及类似的功能,如 Take)

c# - 使用不工作的 Visual Studio 2019 自动导入

C# 处理事件

javascript - 滚动时向图像添加类

javascript - 附加到 javascript 文件的非法字符