WebSecurity - GetUserId()


WebSecurity 对象WebSecurity Object

Definition

GetUserId()The method returns the ID of the specified user.


C# and VB Syntax

WebSecurity.GetUserId(userName)


Parameters

Parameters Type Description
userName String User name


Return Value

Type Description
Integer

User ID



Errors and Exceptions

In the following cases, anyWebSecurityaccess to the object will throw anInvalidOperationException:

  • InitializeDatabaseConnection()the method has not been called
  • SimpleMembershipnot initialized (or disabled in website configuration)

Remarks

The user ID is the primary key of user information stored in the user database.

It is used to identify users in the user profile table and membership table.


Technical Data

Name Value
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll


WebSecurity 对象WebSecurity Object Other Extensions