Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

WebSecurity IsAuthenticated Property

WebSecurity Property - IsAuthenticated


WebSecurity Object WebSecurity object


define

IsAuthenticated The property is a Boolean value indicating whether the current user is authenticated (logged in).

If the current user is authenticated, the property value is a Boolean value true, otherwise it is false。


C# and VB syntax

WebSecurity.IsAuthenticated


Example

Example C#

if (!WebSecurity.IsAuthenticated)

{

Response.Redirect("~/Account/Login");

}

Example VB

if !WebSecurity.IsAuthenticated then

  Response.Redirect("~/Account/Login")

end if


Notes

IsAuthenticated The property is read-only. It cannot be changed through code.


Errors and exceptions

In the following cases, any access to the WebSecurity object will throw an InvalidOperationException:


Technical data

Name Value
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll

WebSecurity Object WebSecurity object