WebSecurity - RequireAuthenticatedUser()
WebSecurity object
define
If the current user is not authenticated,RequireAuthenticatedUserthe **()** 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, any access to the WebSecurity object will throw an InvalidOperationException:
- InitializeDatabaseConnection() The method is not called
- SimpleMembership Not initialized (or disabled in the website configuration)
Notes
RequireAuthenticatedUser() The value 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 the RequireUser() method. To verify whether the user is a member of a role, use the RequireRoles() method.
Technical data
| Name | Value |
|---|---|
| Namespace | WebMatrix.WebData |
| Assembly | WebMatrix.WebData.dll |
WebSecurity object