HttpRequest.IsAuthenticated Właściwość

Definicja

Pobiera wartość wskazującą, czy żądanie zostało uwierzytelnione.

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

Wartość właściwości

true jeśli żądanie jest uwierzytelnione; w przeciwnym razie , false.

Przykłady

Poniższy przykład kodu używa IsAuthenticated właściwości , aby określić, czy bieżące żądanie zostało uwierzytelnione. Jeśli żądanie nie zostało uwierzytelnione, jest przekierowywane do innej strony, na której użytkownicy mogą wprowadzać swoje poświadczenia do aplikacji internetowej. Jest to typowa technika używana na stronie domyślnej aplikacji.

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

Dotyczy