asp.net安全cookie

标签 asp.net cookies session-cookies

我想保护我的cookie,我读了ASP.NET_SessionId cookie的“HTTPOnly”和“Secure” cookie标志。
我在VS中创建新的asp.net项目。在Inspectors中的 fiddler 中-> raw我有:

Cookie: DXCurrentThemeMVC=Office2010Black; ASP.NET_SessionId=1gq0t1mi234xyljqnxrzbqfx

然后我修改web.config:
<system.web>
    <compilation debug="true" targetFramework="4.0" />

    <httpCookies httpOnlyCookies="true" requireSSL="true"/>

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" requireSSL="true" />
    </authentication>

但是在 fiddler 中相同的数据
 Cookie: DXCurrentThemeMVC=Office2010Black; ASP.NET_SessionId=1gq0t1mi234xyljqnxrzbqfx

我想当我添加
<httpCookies httpOnlyCookies="true" requireSSL="true"/>我看不到 fiddler 中的cookie,否则cookie将被加密。这是正确的结果吗?还是我在某处有错误?

编辑

以及为什么我看不到 fiddler
Set-Cookie: ASP.NET_SessionId=ig2fac55; path=/; secure; HttpOnly

但是只有cookie没有设置,并且安全,并且在Firebug中也只有HttpOnly,我看到了相同的结果

EDIT2
似乎我发现了我的问题:我在iis上托管应用程序并在Firebug中寻找cookie,并且我有带有安全和httpOnly标志的cookie:
ASP.NET_SessionId=98sfd90sdf89sd0f80s8; path=/; secure; HttpOnly

最佳答案

看一下MSDN中的httpCookies Element session 。

httpOnlyCookies 设置响应 header 中的HttpOnly标志。
请参阅Protecting Your Cookies: HttpOnly文章。

requireSSL 强制cookie通过安全 channel 进行传输,因此不会删除它,并且会在传输过程中对其进行加密。

关于asp.net安全cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8852194/

相关文章:

asp.net - 我的事件日志充满了 ViewState 无效和未处理的异常

authentication - nginx代理认证拦截

ios - 您能否删除 iOS 移动设备上安装程序用户代理(不同于 Safari)使用的 cookie?

javascript - Cookie 并不总是保存 > 触发基于 cookie 的功能

angular - 浏览器关闭时如何删除 cookie?使用 angular2-cookies

http - 戈朗 : how to make http client not following redirects?

c# - 从下拉选择中选择 * C#

asp.net - @Html.DisplayFor - 日期格式 ("mm/dd/yyyy")

php - Symfony 1.4 cookie 问题

asp.net - 在 ASP.NET 网站中使用 SQL Server Compact Edition