HttpRequest.IsAuthenticated Propriété

Définition

Obtient une valeur indiquant si la requête a été authentifiée.

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

Valeur de propriété

Boolean

true si la demande a été authentifiée ; sinon, false.

Exemples

L’exemple de code suivant utilise la IsAuthenticated propriété pour déterminer si la requête actuelle a été authentifiée. S’il n’a pas été authentifié, la demande est redirigée vers une autre page dans laquelle les utilisateurs peuvent entrer leurs informations d’identification dans l’application web. Il s’agit d’une technique courante utilisée dans la page par défaut d’une 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

S’applique à