Export (0) Print
Expand All

WebSecurity.GetUserId Method

Returns the ID for a user based on the specified user name.

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

'Declaration
Public Shared Function GetUserId ( _
	userName As String _
) As Integer
'Usage
Dim userName As String
Dim returnValue As Integer

returnValue = WebSecurity.GetUserId(userName)

Parameters

userName
Type: System.String
The user name.

Return Value

Type: System.Int32
The user ID.

ExceptionCondition
InvalidOperationException

The SimpleMembershipProvider.Initialize(String, NameValueCollection) method was not called.

-or-

The InitializeDatabaseConnection method was not called.

-or-

The SimpleMembershipProvider membership provider is not registered in the configuration of your site. For more information, contact your site's system administrator.

The ID represents the key under which the user profile is stored. The same ID is used to identify a user both in the user profile table and in the membership table.

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