So I'm making a asp.net login. I want the login name that people use to match an id in my SQL database. So that I can retrieve their information. But currently when I use the code below, from which I get the name of the computer I am currently on. However I would like the user Identity to be
what they write in
the username textbox
at the login screen.
If HttpContext.Current.User.Identity.IsAuthenticated Then
Dim userName As String = HttpContext.Current.User.Identity.Name
Response.Write(userName)
End If
So I looked for it on net and I think it might have something to do with my web.config file. As I'm totally new to asp.net I wouldn't know. However here's a part of my Web.config file.
<authentication mode="Forms">
<forms name=".ASPXFORMSAUTH"
loginUrl="Login.aspx"
protection="All"
timeout="30"
path="/" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
so any ideas? :)
set login name using
FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked);
and retrive using
User.Identity.Name
reference links, bytes.com and asp.net tutorial
使用ViewStates维护用户的登录状态。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.