Rui*_*ues 6 c# asp.net-mvc-5 asp.net-identity
我正在使用 asp.net MVC 5.2 和 asp.net 身份版本 2.2.1 和实体框架 6.1.3。在某些时候,在控制器中,我需要知道当前正在使用的 AuthenticationProperties 的内容,更具体地说,我需要知道 isPersistent 的值。
Nee*_*eel -1
也许这可以帮助:
var isPersistent = ((System.Web.Security.FormsIdentity) User.Identity).Ticket.IsPersistent;
Run Code Online (Sandbox Code Playgroud)
或者
FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
var isPersistent = ticket.IsPersistent.ToString();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2007 次 |
| 最近记录: |