保存登录名在asp.net当前用户身份 [英] saving the login name as current user identity in asp.net
问题描述
所以,我正在做一个asp.net登录。我想,人们用它来搭配一个id在我的SQL数据库的登录名。所以,我可以取回他们的信息。但是,目前,当我使用code以下,从中我得到我目前的计算机的名称。不过,我希望用户身份是
他们写的东西在
用户名文本
在登录屏幕上。
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
所以,我看着它在网上,我认为它可能是与我的web.config文件。当我完全陌生asp.net我不知道。但这里是我的Web.config文件的一部分。
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? :)
推荐答案
设置使用登录名
FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked);
和retrive使用
User.Identity.Name
这篇关于保存登录名在asp.net当前用户身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!