Latest web development tutorials

WebSecurity RequireAuthenticatedUser method

WebSecurity objects WebSecurity objects

definition

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


C # and VB syntax

WebSecurity.RequireAuthenticatedUser()


parameter

no.


return value

no.


Errors and exceptions

In the following scenario, any access to WebSecurity object will throw an InvalidOperationException:

  • InitializeDatabaseConnection () method has not been called
  • SimpleMembership not initialized (or disabled in the site configuration)

Remark

RequireAuthenticatedUser () value to verify whether the current user has been authenticated. If the current user is not authenticated, the HTTP status is set to 401 (Unauthorized).

To verify that the current user is the specified user (by ID or by name), use RequireUser () method. To verify that the user is a member of a role, use RequireRoles () method.


Technical data

名称
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll


WebSecurity objects WebSecurity objects