HttpRequest.IsAuthenticated HttpRequest.IsAuthenticated HttpRequest.IsAuthenticated HttpRequest.IsAuthenticated Property

定义

获取一个值,该值指示是否验证了请求。Gets a value indicating whether the request has been authenticated.

public:
 property bool IsAuthenticated { bool get(); };
public bool IsAuthenticated { get; }
member this.IsAuthenticated : bool
Public ReadOnly Property IsAuthenticated As Boolean

属性值

如果请求已经过身份验证,则为 true;否则,为 falsetrue if the request is authenticated; otherwise, false.

示例

下面的代码示例使用IsAuthenticated属性来确定当前请求是否已经过身份验证。The following code example uses the IsAuthenticated property to determine whether the current request has been authenticated. 如果尚未对其进行身份验证,则会将请求重定向到另一个页面,用户可在其中向 Web 应用程序输入其凭据。If it has not been authenticated, the request is redirected to another page where users can enter their credentials into the Web application. 这是在应用程序的默认页中使用的常用技术。This is a common technique used in the default page for an application.

private void Page_Load(object sender, EventArgs e)
{
    // Check whether the current request has been
    // authenticated. If it has not, redirect the 
    // user to the Login.aspx page.
    if (!Request.IsAuthenticated)
    {
        Response.Redirect("Login.aspx");
    }
}
Private Sub Page_Load(sender As Object, e As EventArgs)
    ' Check whether the current request has been
    ' authenticated. If it has not, redirect the 
    ' user to the Login.aspx page.
    If (Request.IsAuthenticated = False) Then
        Response.Redirect("Login.aspx")
    End If
End Sub

适用于