HttpRequest.IsAuthenticated Proprietà

Definizione

Ottiene un valore che indica se la richiesta è stata autenticata.

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

Valore della proprietà

Boolean

true se la richiesta viene autenticata; in caso contrario, false.

Esempio

Nell'esempio di codice seguente viene utilizzata la IsAuthenticated proprietà per determinare se la richiesta corrente è stata autenticata. Se non è stato autenticato, la richiesta viene reindirizzata a un'altra pagina in cui gli utenti possono immettere le credenziali nell'applicazione Web. Si tratta di una tecnica comune usata nella pagina predefinita per un'applicazione.

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

Si applica a