WebSecurity - RequireAuthenticatedUser()
WebSecurity Object
Definition
If the current user is not authenticated,RequireAuthenticatedUser()the method sets the HTTP status to 401 (Unauthorized).
C# and VB Syntax
WebSecurity.RequireAuthenticatedUser()
Parameters
None.
Return Value
None.
Errors and Exceptions
In the following cases, anyWebSecurityaccess to the object will throw anInvalidOperationException:
- InitializeDatabaseConnection()method has not been called
- SimpleMembershipnot initialized (or disabled in website configuration)
Remarks
RequireAuthenticatedUser()This method verifies whether the current user is authenticated. If the current user is not authenticated, the HTTP status is set to 401 (Unauthorized).
To verify whether the current user is the specified user (by ID or by name), use theRequireUser()method. To verify whether the user is a member of a role, use theRequireRoles()method.
Technical Data
| Name | Value |
|---|---|
| Namespace | WebMatrix.WebData |
| Assembly | WebMatrix.WebData.dll |
WebSecurity Object Other Extensions