且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

表单身份验证在MVC 4中不使用coockies

更新时间:2023-12-01 19:57:22

网络是无状态的,因此它使用cookie来存储状态,例如用户是否经过身份验证或不。如果您想使用没有cookie的表单身份验证,那么您可以启用cookieless身份验证



https://msdn.microsoft.com/en-us/library/system.web.configuration.formsauthenticationconfiguration.cookieless(v = vs.110).aspx [ ^ ]



将模式设置为UseUri。但是这有不利之处



https: //msdn.microsoft.com/en-us/library/aa479315.aspx [ ^ ]



除了使用基本身份验证或Windows身份验证之外,您唯一的另一种选择是不使用表单身份验证。还有一个选择就是挑战为什么你不能使用cookies作为这个决定背后的原因可能是有缺陷的。
The web is stateless so it uses cookies to store state such as if the user is authenticated or not. If you want to use forms authentication without cookies then you can enable cookieless authentication

https://msdn.microsoft.com/en-us/library/system.web.configuration.formsauthenticationconfiguration.cookieless(v=vs.110).aspx[^]

Set the mode to UseUri. However there are downsides to this

https://msdn.microsoft.com/en-us/library/aa479315.aspx[^]

Your only other alternative is to not use forms auth at all but use Basic Authentication or Windows Authentication. Yet one more option would be to challenge why you can't use cookies as the reasoning behind that decision is probably flawed.