WebSecurity Property - CurrentUserName


❮ 网络安全

定义

CurrentUserName 属性是 WebSecurity 数据库中用户配置文件表中当前用户的名称。


C# 和 VB 语法

WebSecurity.CurrentUserName

实例

实例 C#

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

<p>Welcome @value</p>

实例 VB

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

<p>Welcome @value</p>

备注

CurrentUserName 属性是只读的。 无法通过代码更改。


错误和异常

在以下情况下,对 WebSecurity 对象的任何访问都会引发 InvalidOperationException

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

❮ 网络安全