0
다른 변수를 제어하는 데 사용할 AuthCookie에서 사용자 이름을 얻으려고합니다. 쿠키는 여기에 인덱스에 정의되어 있습니다 : 여기 변수에 선언하려고Forms 공유 쿠키를 공용 공유 변수에서 사용할 문자열로 변환
<HttpPost()> _
Public Function Index(model As users.LogOnModel) As ActionResult
'call LogOnModel
'--------------------------
If ModelState.IsValid Then
'check username and password
If model.pwd = db.users.First(Function(t) t.NT_id = model.NT_id).pwd Then
'create an authentication cookie
FormsAuthentication.SetAuthCookie(model.NT_id, False) 'set to false to destroy cookie on browser close
'redirect action if login is successful
Return RedirectToAction("Construction", "Home")
Else
ModelState.AddModelError("", "Invalid Username or Password")
End If
End If
Return View(model)
End Function
는 다른 변수를 제어하기 위해 사용되는 :
' User variables
'---------------------------
Public Shared uNT_id = IF(HttpContext.Current.User.Identity.Name is nothing, System.Environment.UserName, Trycast(HttpContext.Current.User.Identity.Name, String))
Public Shared uid = db_apps.app_users.First(Function(t) t.NT_id = uNT_id).app_user_id
Public Shared ussn = db_apps.app_users.First(Function(t) t.NT_id = uNT_id).ssn
Public Shared upwd = db_apps.app_users.First(Function(t) t.NT_id = uNT_id).pwd
Public Shared uname_first = db_apps.app_users.First(Function(t) t.NT_id = uNT_id).name_first
' App variables
'---------------------------
Public Shared appcount = db_apps.app_users.Count(Function(t) t.NT_id = uNT_id)
Public Shared Function appid_multiple() As String
Dim appidQ = From v In db_apps.app_users
Where v.NT_id = uNT_id
Select v
'Create a String representation
Dim stringList As New System.Text.StringBuilder
Dim counter As Integer = 0
For Each v In appidQ
stringList.Append(v.app_id.ToString())
'Separator
If Not counter = appidQ.Count - 1 Then
stringList.Append(",")
End If
counter += 1
Next
Return stringList.ToString
End Function
Public Shared appid = db_apps.app_users.First(Function(t) t.NT_id = uNT_id).app_id
그 결과 중 하나를 동일에 uNT_id 요구이다 그들이 가진 웹 사이트, 또는 그들이 거기 컴퓨터에 로그온 한 사용자 이름에 로그인 사용자 이름이 너무 예를 들어 나의해야한다 :
uNT_id = "z148658"
및 그런 다음 uNT_id를 사용하여이 모든 다른 변수를 제어 할 것입니다.