
For a web application I switched from using ASP.NET Membership to using my own log in system which just does something like this to mark a user as logged in:
Session["UserId"] = User.Id
Is it possible to store the user id in the ASPXAUTH cookie, piggybacking on its encryption, instead of using the standard session?
The goal is for the logged in state to last longer than a session and survive both browser and server restarts.
Update: The original answer provided was with a project using MembershipProvider and it's explained in the answer itself. I, the asker, am not using it, so the answer to my problem was slightly different but extracted from this answer. I'm putting my answer at the bottom for anyone that cares and leaving the original verbatim, as it contains a lot of value.
Yes, you can use FormsAuthentication for your own strategy. And while the asp.net db structure does not suit you, you may provide a implementation of MembershipProvider to allow use of the Membership infrastructure. These two functionalities are not married so you may decide what fits for you.
Keeping in mind your question and some of the comments, here is a runnable example of how it is to leverage the provider model without being married to the default implementations and db schemas.
Using forms auth for your own purposes is . You just need to provide authentication and set your own ticket (cookie).
Using custom membership is almost as . You can implement as little or as much of the provider as you need to support the asp.net infrastructure features that you would like to employ.
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-51660-1.html
为什么要彼此伤害
集体向520万刷起来集体心意送给烊烊生日礼物#易烊千玺##易烊千玺真的很不错##全员即刻加速1128迈#
朦胧花季
当初在西湖边忽悠外国老人