将会话cookie http和secure设置为true的问题

Rah*_*mba 6 c# security asp.net-mvc owasp session-cookies

我有一个基于Asp.net MVC 4的项目,在我们的应用程序中,我们需要使会话cookie安全.

我已经尝试过这段代码来保证我的cookie安全.

var encryptedTicket = FormsAuthentication.Encrypt(authenticationTicket);
httpContext.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) { Secure = true, HttpOnly = true });
Run Code Online (Sandbox Code Playgroud)

也在webconfig文件中

<httpCookies httpOnlyCookies="true" requireSSL="true" />
Run Code Online (Sandbox Code Playgroud)

问题是当我使用HttpOnly = true时,应用程序能够成功创建cookie.

但是当我尝试使用secure = true时,没有创建cookie并且用户永远不会登录.

登录后 在此输入图像描述 有人可以帮助我在哪里出错.

提前致谢.