How to get recently authenticated user?

前端 未结 2 1075
野趣味
野趣味 2021-01-25 12:03

I am working with MVC 3 and I have just implemented a wrapper for the FormsAuthenticationService.

Something similar to the following.

public void SignIn(         


        
2条回答
  •  暖寄归人
    2021-01-25 12:32

    You haven't actually stored a user id in the database. All the code that you've written does is store an authentication cookie on the users computer, either as a session cookie (not persistent) or as a persistent one.

    When your page refreshes, it will get the cookie automatically, decode it, and populate the IPrincipal object which you access from the User.Current property of your controller.

提交回复
热议问题