How can I set the Secure flag on an ASP.NET Session Cookie, so that it will only be transmitted over HTTPS and never over plain HTTP?
相关问题
- Session ID not random enough - ASP.NET
- Invalid Arguments error in Global.asax in mvc
- DataServiceRequestException with TableStorageSessi
- How maintain session beetween two Url in asp. Net
- Does ASP .NET Session reset after login?
相关文章
- Session ID not random enough - ASP.NET
- ASP.NET MVC 3 - 用Session变量处理(ASP.NET MVC 3 - Deal
- Invalid Arguments error in Global.asax in mvc
- DataServiceRequestException with TableStorageSessi
- How maintain session beetween two Url in asp. Net
- Does ASP .NET Session reset after login?
- 是什么Session.Abandon()和Session.Clear之间的差异()(What is
- 如何设置安全标志上的ASP.NET会话Cookie?(How can I set the Secur
There are two ways, one
httpCookies
element inweb.config
allows you to turn onrequireSSL
which only transmit all cookies including session in SSL only and also inside forms authentication, but if you turn on SSL on httpcookies you must also turn it on inside forms configuration too.Edit for clarity: Put this in
<system.web>
Things get messy quickly if you are talking about checked-in code in an enterprise environment. We've found that the best approach is to have the web.Release.config contain the following:
That way, developers are not affected (running in Debug), and only servers that get Release builds are requiring cookies to be SSL.
In the
<system.web>
element, add the following element:However, if you have a
<forms>
element in yoursystem.web\authentication
block, then this will override the setting inhttpCookies
, setting it back to the defaultfalse
.In that case, you need to add the
requireSSL="true"
attribute to the forms element as well.So you will end up with:
See here and here for MSDN documentation of these elements.