【发布时间】:2011-04-26 11:23:59
【问题描述】:
我有一个使用身份验证服务的 MVC 应用程序,使用返回 true/false 的 IsAuthenticated() 方法。
它似乎没有连接到 FormsAuthentication.SignOut() 方法,或者当我在登录时添加新的授权 cookie 时。
登录:
HttpContext.Current.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket)));
退出:
FormsAuthentication.SignOut();
我的控制器上有一个自定义授权属性,它使用 IsAuthenticated() 调用身份验证服务,但它返回错误的值。
有谁知道为什么下面的代码有时会返回真或假?
userPrincipal.Identity.IsAuthenticated
【问题讨论】:
标签: asp.net asp.net-mvc-3 forms-authentication