ASP.NET中Request.IsAuthenticated和Request.User.Identity.IsAuthenticated的区别

Reflector 查看 System.Web.dll 中 HttpRequest.cs 的代码:

public bool IsAuthenticated
{
    get
    {
        return (((this._context.User != null) && (this._context.User.Identity != null)) && this._context.User.Identity.IsAuthenticated);
    }
}
 

所以说这两者应该是没区别的,不过因为加了一些判断的因素,看来使用 Request.IsAuthenticated 会保险一点。

浏览器没那么聪明!
原文地址:https://www.cnblogs.com/rulee/p/2482495.html