Latest web development tutorials

WebSecurity UserExists 方法

WebSecurity 對象 WebSecurity對象

定義

UserExists()方法指示用戶是否已存在於WebSecurity數據庫中。


C# 和VB 語法

WebSecurity.UserExists( userName )


參數

参数 类型 描述
userName String 用户名


返回值

类型 描述
Boolean 如果用户已存在,则返回 true ,否则返回 false


錯誤和異常

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

  • InitializeDatabaseConnection() method has not been called
  • SimpleMembership沒有初始化(或者在網站配置中禁用)

備註

UserExists()方法只驗證用戶是否已存在於用戶資料表中。

不會為用戶驗證會員帳戶是否已存在,或者用戶是否已確認,或者用戶是否已登錄。


技術數據

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


WebSecurity 對象 WebSecurity對象