这是我的登录操作:
Public Function LogOn(ByVal model As LogOnModel, ByVal returnUrl As String) As ActionResult
If ModelState.IsValid Then
If Membership.ValidateUser(model.UserName, model.Password) Then
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe)
If Url.IsLocalUrl(returnUrl) AndAlso returnUrl.Length > 1 AndAlso returnUrl.StartsWith("/") _
AndAlso Not returnUrl.StartsWith("//") AndAlso Not returnUrl.StartsWith("/\\") Then
Return Redirect(returnUrl)
Else
' redirect based on whether the user is admin, company owner, or blog owner
Debug.Print(Membership.GetUser.UserName)
当我尝试调试变量时,它显示“NullReferenceException,对象引用未设置为对象的实例”。
它只是在一分钟前工作!如何获取用户名变量?谢谢。