Export (0) Print
Expand All

WebSecurity.RequireAuthenticatedUser Method

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

Namespace:  WebMatrix.WebData
Assembly:  WebMatrix.WebData (in WebMatrix.WebData.dll)

public static void RequireAuthenticatedUser()

This method validates that the current user is authenticated. If the current user is not authenticated, the HTTP status is set to 401 (Unauthorized).

To validate that the current user is a specific user (by user ID or by user name), use the RequireUser() method. To validate that a user is a member of a role or set of roles, use the RequireRoles(String[]) method.

For an example of how to use the RequireAuthenticatedUser() method, see the Logout.cshtml file in the Starter Site template.

  • Medium trust for the immediate caller. This member can be used by partially trusted code.
Show:
© 2014 Microsoft