开发者

saving the login name as current user identity in asp.net

开发者 https://www.devze.com 2023-02-14 14:37 出处:网络
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 开发者_如何学Cretrieve their information. But currently when I use the code below

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 开发者_如何学Cretrieve 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


Use the ViewStates to maintain the Login state of the user.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号