WebSecurity - GetUserId()
WebSecurity object
define
GetUserId() The method returns the ID of the specified user.
C# and VB syntax
WebSecurity.GetUserId(
userName
)
Parameters
| Parameters | Type | Description |
|---|---|---|
| userName | String | Username |
Return Value
| Type | Description |
|---|---|
| Integer |
The user ID |
Errors and exceptions
In the following cases, any access to the WebSecurity object will throw an InvalidOperationException:
- InitializeDatabaseConnection() The method is not called
- SimpleMembership Not initialized (or disabled in the website configuration)
Notes
The user ID is the primary key of the user information stored in the user database.
It is used to identify the user in the user profile table and the membership table.
Technical data
| Name | Value |
|---|---|
| Namespace | WebMatrix.WebData |
| Assembly | WebMatrix.WebData.dll |
WebSecurity object