自强学堂
自强学堂:学习、分享、让你更强!
Razor 实例HTMLCSSJAVASCRIPTJQUERYSQLPHPBOOTSTRAPANGULARXML
 

WebSecurity CurrentUserName 属性

WebSecurity 对象 WebSecurity 对象

定义

CurrentUserName 属性是当前用户在 WebSecurity 数据库中用户资料表中的名称。


C# 和 VB 语法

WebSecurity.CurrentUserName


实例

实例 C#

@{
string value;
value=WebSecurity.CurrentUserId;
}

<p>Welcome @value</p>

实例 VB

@Code
Dim value as String
value=WebSecurity.CurrentUserName
End Code

<p>Welcome @value</p>


备注

CurrentUserName 属性是只读的。它不能通过代码更改。


错误和异常

在下面的情况下,任何对 WebSecurity 对象的访问将抛出一个 InvalidOperationException

  • InitializeDatabaseConnection() 方法没有被调用
  • SimpleMembership 没有初始化(或者在网站配置中禁用)

技术数据

名称
NamespaceWebMatrix.WebData
AssemblyWebMatrix.WebData.dll


WebSecurity 对象 WebSecurity 对象