WebSecurity IsAuthenticated property
definition
IsAuthenticated attribute is a Boolean value that indicates whether the current user has been authenticated (logged in).
If the current user has been authenticated, the attribute value is a Boolean value true, otherwise it is false.
C # and VB syntax
WebSecurity.IsAuthenticated
Examples
Examples of C #
if (!WebSecurity.IsAuthenticated)
{
Response.Redirect("~/Account/Login");
}
{
Response.Redirect("~/Account/Login");
}
Examples VB
if !WebSecurity.IsAuthenticated then
Response.Redirect("~/Account/Login")
end if
Response.Redirect("~/Account/Login")
end if
Remark
IsAuthenticated property is read-only. It can not change the code.
Errors and exceptions
In the following scenario, any access to WebSecurity object will throw an InvalidOperationException:
- InitializeDatabaseConnection () method has not been called
- SimpleMembership not initialized (or disabled in the site configuration)
Technical data
名称 | 值 |
---|---|
Namespace | WebMatrix.WebData |
Assembly | WebMatrix.WebData.dll |
WebSecurity objects