WebSecurity.IsAuthenticated Property

Gets the authentication status of the current user.

Namespace:  WebMatrix.WebData
Assembly:  WebMatrix.WebData (in WebMatrix.WebData.dll)

public static bool IsAuthenticated { get; }

Property Value

Type: System.Boolean
true if the current user is authenticated; otherwise, false. The default is false.

The following example shows how to use the IsAuthenticated method to verify that the current user is authenticated.

if (!WebSecurity.IsAuthenticated)
    // If this page is accessed before the user logs in, notify the user.
    <p>You must first log in to access the rest of this page.</p>
    <p>Click <a href="WebSecurityLogin.cshtml">here</a> to log in.</p>

  • Medium trust for the immediate caller. This member can be used by partially trusted code.