Met Websecurity Requireauthenticateduser
# WebSecurity - RequireAuthenticatedUser()
* * WebSecurity Object](#)
* * *
## Definition
If the current user is not authenticated, the **RequireAuthenticatedUser()** 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**:
* The **InitializeDatabaseConnection()** method has not been called
* **SimpleMembership** is not initialized (or is disabled in the site configuration)
* * *
## Remarks
The **RequireAuthenticatedUser()** 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 if the current user is a specific user (by ID or by name), use the **RequireUser()** method. To verify if 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](#)
YouTip