即使另一个用户登录,current.user.identity仍然相同 [英] current.user.identity remains same even if another user logs in

查看:49
本文介绍了即使另一个用户登录,current.user.identity仍然相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图根据用户ID在下拉列表中显示项目.问题是即使我使用不同的用户名登录,也选择了我登录时使用的前一个或第一个用户名.像这样.

使用
在另一个Web表单中获取用户名 字符串用户名= HttpContext.Current.User.Identity.Name;

和用户名始终保留一个人的名字..对于登录即时消息,使用:

 公共  void  btnlogin_Click(对象发​​件人,EventArgs e)
  {
      使用(DirectoryEntry条目=  DirectoryEntry())
      {
          //  Session ["username"] = txtusername; 
          entry.Username = txtusername.Text;
          entry.Password = txtpassword.Text;

          DirectorySearcher searcher =  DirectorySearcher(entry);

          searcher.Filter = " ;

          尝试
          {
              searcher.FindOne();

              lblrem.Text = " ;
              Response.Redirect(" );
          }
          捕获(以前是COMException)
          {
              如果(例如ErrorCode == -2147023570)
              {
                  lblrem.Text = " ;
              }
          }
      } 

解决方案

清除cookie并重试,或者在其他浏览器中尝试,您是否使用过cookie的持久状态? blockquote>

如果您没有其他浏览器,则可以尝试"InPrivate浏览"选项.
如果问题仍然存在,则需要通过调试检查代码.

问候,
Venugopal


Im trying to display items in a dropdown list according to the user id.The problem is that even though I log in with a diffrent username the previous or the very first username that i logged with is picked.I dnt know why its behaving like this.

To get the username in another web form im using
string username = HttpContext.Current.User.Identity.Name;

and username always remains of one persons name..and for the login im using:

public void btnlogin_Click(object sender, EventArgs e)
  {
      using (DirectoryEntry entry = new DirectoryEntry())
      {
          //Session["username"] = txtusername;
          entry.Username = txtusername.Text;
          entry.Password = txtpassword.Text;

          DirectorySearcher searcher = new DirectorySearcher(entry);

          searcher.Filter = "(objectclass=user)";

          try
          {
              searcher.FindOne();

              lblrem.Text = "Successfull";
              Response.Redirect("Default2.aspx");
          }
          catch (COMException ex)
          {
              if (ex.ErrorCode == -2147023570)
              {
                  lblrem.Text = "Login Failed.Please ensure that your username and password is correct";
              }
          }
      }

解决方案

clear cookies and try again, or try in different browser, did u use persistant state of cookie>>>>


If you don''t have a different browser, you can try the "InPrivate Browsing" option.
And if the problem still persists you need to check your code through debugging.

Regards,
Venugopal


这篇关于即使另一个用户登录,current.user.identity仍然相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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