2009-09-04 33 views

回答

43

絕對沒有區別。 Checkout HttpContext.Current.Request.IsAuthenticated implementation:

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

Thanks。它看起來像使用HttpContext.Current.Request.IsAuthenticated更好,因爲它檢查User等不爲null。 – Anthony 2009-09-04 14:28:20

+0

Yeap,只需要確保HttpContext.Current.Request不爲null。 – 2009-09-04 14:30:40

+10

只是一些挑剔的,但它不完全相同,因爲當用戶或用戶的身份爲空時,調用不可互換... – 2009-09-04 14:30:47