Latest web development tutorials

WebSecurity GetUserId 方法

WebSecurity 對象 WebSecurity對象

定義

GetUserId()方法返回指定用戶的ID。


C# 和VB 語法

WebSecurity.GetUserId( userName )


參數

参数 类型 描述
userName String 用户名


返回值

类型 描述
Integer

用户 ID



錯誤和異常

在下面的情況下,任何對WebSecurity對象的訪問將拋出一個InvalidOperationException

  • InitializeDatabaseConnection()方法沒有被調用
  • SimpleMembership沒有初始化(或者在網站配置中禁用)

備註

用戶ID 是存儲在用戶數據庫中的用戶信息的主鍵。

它是用於在用戶資料表和會員表中識別用戶。


技術數據

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


WebSecurity 對象 WebSecurity對象