WebSecurity.RequireUser Method

Include Protected Members
Include Inherited Members

If the current user is not the specified user, sets the HTTP status to 401 (Unauthorized).

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

Overload List

  Name Description
Public methodStatic member RequireUser(Int32) If the specified user is not logged on, sets the HTTP status to 401 (Unauthorized).
Public methodStatic member RequireUser(String) If the current user does not match the specified user name, sets the HTTP status to 401 (Unauthorized).

Top

Remarks

To validate that the user is authenticated, use the RequireAuthenticatedUser() method. To validate that a user is a member of a role or set of roles, use the RequireRoles(String[]) method.

Note

This method will let only the specified user access the web page. The recommended way to restrict access to a web page is to create a role, and use the RequireRoles(String[]) method to verify that the current user is a member of that role.

See Also

Reference

WebSecurity Class

WebMatrix.WebData Namespace