HttpRequest.IsAuthenticated プロパティ

定義

要求が認証されているかどうかを示す値を取得します。

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

プロパティ値

要求が認証されている場合は true。それ以外の場合は false

次のコード例では、 プロパティを IsAuthenticated 使用して、現在の要求が認証されているかどうかを判断します。 認証されていない場合、要求は別のページにリダイレクトされ、ユーザーは資格情報を Web アプリケーションに入力できます。 これは、アプリケーションの既定のページで使用される一般的な手法です。

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

適用対象