FormsAuthentication - handling a change of username

前端 未结 1 1901
礼貌的吻别
礼貌的吻别 2021-02-14 14:03

My ASP.NET MVC web application allows administrators to change their own, or other users\' usernames.

Users are logged in by calling FormsAuthentication.SetAuthCoo

相关标签:
1条回答
  • 2021-02-14 14:38
    var cookieName = FormsAuthentication.FormsCookieName;
    var request = HttpContext.Current.Request;
    var cookie = request.Cookies.Get(cookieName);
    if (cookie == null)
        return;
    
    try
    {
        var ticket = FormsAuthentication.Decrypt(cookie.Value);
    
        //This should give you what you want...
        bool isPersistent = ticket.IsPersistent;
    }
    catch (Exception ex)
    {
        //Logging
    }
    
    0 讨论(0)
提交回复
热议问题