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

適用於