The RequireUser() method sets the HTTP status to 401 (Unauthorized) if the specified user is not logged on.
Parameter | Type | Description |
---|---|---|
userID | Integer | The user ID |
userName | String | The user name |
None.
Any access to the WebSecurity object throws an InvalidOperationException if:
RequireUser() verifies that the current user is the specified user.
To validate that the user is authenticated, use RequireAuthenticatedUser() instead.
To validate that a user is a member of a role (roles), use RequireRoles().
RequireUser() lets only the specified user access the web page. The recommended way to restrict access to a page is to create a role, and use the RequireRoles() method to verify that the user is a member of that role.
Name | Value |
---|---|
Namespace | WebMatrix.WebData |
Assembly | WebMatrix.WebData.dll |