且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

会话使用asp.net与不同的登录冲突

更新时间:2023-02-16 07:36:49

Hey Raghupathirao,



(我会使用开启roleid)



无论如何,看起来它可能与你的功能有关:

_ objDataSet =(DataSet)_objMasters.fnGetData();





你确定你是对的吗? _objDataSet 回到那个电话?



* btw,我会用switch-caseon roleid那里



干杯,

Edo te>

HI,



最后使用
   {
if (_ objMasters!= null
{
_objMasters = null ;
}
}

在代码中阻塞并在那里处理 _objMasters 对象并为该对象分配null。



这可能会解决您的问题。



谢谢


hi all,

i faced Session Conflicts with different logins using asp.net

When two users access the same page, during post back user1 gets user2 page.

Login Button Code


protected void btn_log_loginin_Click(object sender, EventArgs e)
   {
       try
       {
           _objMasters = new TRANSACTIONBAL();
           _objMasters.ScreenInd = TRANSACTION.userlogin;
           _objMasters.loginname = txt_log_username.Text;
           _objMasters.password = txt_log_password.Text;
           _objDataSet = (DataSet)_objMasters.fnGetData();
           if (_objDataSet != null)
           {
               roleid = Convert.ToInt32(_objDataSet.Tables[0].Rows[0][1]);
           }
           if (roleid == 0)
           {
               loginmsgdsply.Text = "Invalid Login/Inactive Member";
           }
           else if (roleid == 1)
           {
               Session["username"] = txt_log_username.Text;
               Session["Empid"] = _objDataSet.Tables[0].Rows[0][0];
               Session["roleid"] = _objDataSet.Tables[0].Rows[0][1];
               Session["Jobid"] = _objDataSet.Tables[0].Rows[0][2];
               Session["JoinDate"] = _objDataSet.Tables[0].Rows[0][3];

               Response.Redirect("~/Employeedirectory.aspx");
           }
           else if (roleid != 0 && roleid != 1)
           {
               if (_objDataSet.Tables[0].Rows.Count > 0)
               {
                   Session["username"] = txt_log_username.Text;
                   Session["Empid"] = _objDataSet.Tables[0].Rows[0][0];
                   Session["roleid"] = _objDataSet.Tables[0].Rows[0][1];
                   Session["Jobid"] = _objDataSet.Tables[0].Rows[0][2];
                   Session["JoinDate"] = _objDataSet.Tables[0].Rows[0][3];

                  Response.Redirect("~/Default.aspx");
               }
               else
               {
                   loginmsgdsply.ForeColor = Color.Red;
                   loginmsgdsply.Text = "Invalid Login";
               }
           }
       }
       catch (Exception ex)
       {
           //LogError("QuestionBank.aspx", "fnLoadPage", DateTime.Now, ex.Message.ToString());
           //Response.Redirect("Error.aspx", false);
       }
   }

Hey Raghupathirao,

(I would use switch on "roleid")

Anyway, is looks like it might be something with your function:
_objDataSet = (DataSet)_objMasters.fnGetData();



did you make sure that you get the right _objDataSet back on that call?

* btw, I would use "switch-case" on "roleid" there

Cheers,
Edo


HI,

Use a
finally{ 
   if(_objMasters != null)
   {
     _objMasters = null;
   }
 }

block in your code and dispose your _objMasters object there and assign null to that object.

This may resolve your problem.

Thanks