Bagikan melalui


HttpRequest.IsAuthenticated Properti

Definisi

Mendapatkan nilai yang menunjukkan apakah permintaan telah diautentikasi.

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

Nilai Properti

true jika permintaan diautentikasi; jika tidak, false.

Contoh

Contoh kode berikut menggunakan IsAuthenticated properti untuk menentukan apakah permintaan saat ini telah diautentikasi. Jika belum diautentikasi, permintaan dialihkan ke halaman lain tempat pengguna dapat memasukkan kredensial mereka ke dalam aplikasi Web. Ini adalah teknik umum yang digunakan di halaman default untuk aplikasi.

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

Berlaku untuk