保存登录名在asp.net当前用户身份 [英] saving the login name as current user identity in asp.net

查看:132
本文介绍了保存登录名在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

引用链接, bytes.com asp.net教程

这篇关于保存登录名在asp.net当前用户身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆