WebSecurity - IsCurrentUser()


WebSecurity 對象 WebSecurity 對象

定義

IsCurrentUser() 方法把提供的用戶名與已登錄用戶的用戶名進行比較。


C# 和 VB 語法

WebSecurity.IsCurrentUser(userName)


參數

參數 類型 描述
userName String 要比較的用戶名


返回值

類型 描述
Boolean 如果 userName 匹配已登錄用戶,則返回 true,否則返回 false


錯誤和異常

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

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

技術數據

名稱
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll


WebSecurity 對象 WebSecurity 對象