By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,321 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,321 IT Pros & Developers. It's quick & easy.

Session Conflict

P: n/a
Well Guys, Here is a very strange trouble. When more than one users
request tto same page at the same time then our session gets
conflicted.

Moreover I printed my SessionID, strangely but true I got the exact
same SessionID as of other users's.

Well I guess nothing wrong with my code, do I need to set any property
in Web.Config file??

Any help guys???

Thanks
Amit Arora

Apr 15 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Nope the problem is definitely in your code. As long as the web-browser is
sharing the session, you expect conflicts/bleeds. What are you doing in your
code?

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

<ar*********@gmail.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
Well Guys, Here is a very strange trouble. When more than one users
request tto same page at the same time then our session gets
conflicted.

Moreover I printed my SessionID, strangely but true I got the exact
same SessionID as of other users's.

Well I guess nothing wrong with my code, do I need to set any property
in Web.Config file??

Any help guys???

Thanks
Amit Arora

Apr 15 '06 #2

P: n/a
Well when I run my code seprately in dummy project it works fine, but
when I integrate the same in my project it gives me problem......
Well this code executes in separate Left Frame.......

Another thing which comes to my mind is in dummy project I just execute
simple queries but in my original project I use two stored procedures,
can something wrong be here in procedures itself.
Well here goes my code..............

public void GetCompanyContact()
{
string roleid = Session["RoleID"].ToString();
string userid = Session["UserID"].ToString();

SqlConnection con = new
SqlConnection(ConfigurationSettings.AppSettings["CMSConnection"]);
SqlCommand objcomm = new SqlCommand();
DataSet dsCompany=new DataSet();
SqlDataAdapter daCompany = new SqlDataAdapter();
SqlDataAdapter daContact = new SqlDataAdapter();

CommonRules.CommonLogic cmLogic=new CMS.CommonRules.CommonLogic();

int permission=0;
if((cmLogic.isValidServiceItem(Convert.ToInt32(Ses sion["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
try
{
con.Open();
objcomm.CommandText="Usp_LeftMenu_Company";
objcomm.Connection=con;

objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );

objcomm.Parameters.Add(
"@FILTER_ROLEID",Convert.ToInt32(Session["Filterroleid"]));
objcomm.Parameters.Add(
"@FILTER_USERID",Convert.ToInt32(Session["Filteruserid"]));
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Convert.ToInt32(Session["FilterIV"]));
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Convert.ToInt32(Session["FilterDomain"]));
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Convert.ToInt32(Session["FilterSource"]));
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Convert.ToInt32(Session["FilterWorkType"]));
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Convert.ToInt32(Sessio n["FilterDisposition"]));
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"].ToString());
objcomm.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"].ToString());
objcomm.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"].ToString());
daCompany.SelectCommand=objcomm;
daCompany.Fill(dsCompany);

}
finally
{
objcomm.Dispose();
daCompany.Dispose();

}
Session["SelectedContact"]="";

System.Text.StringBuilder strCompany=new
System.Text.StringBuilder();
if (dsCompany.Tables[0].Rows.Count>0)
{
for (int i=0;i<dsCompany.Tables[0].Rows.Count;i++)
{
strCompany.Append("<br>&nbsp;&nbsp;");
strCompany.Append("<input type=checkbox ");
DataSet dsContact =new DataSet();
if(HdnSelectClear.Value=="1")
{
strCompany.Append(" checked");
Session["SelectedCompany"]=Session["SelectedCompany"]+","+
dsCompany.Tables[0].Rows[i][0].ToString();
}
else if(HdnSelectClear.Value=="0")
{
Session["SelectedCompany"]="";
}
else
{
try
{
string [] ArrCompnay=Request.Form["chkCompany"].Split(new char[]
{','});
foreach (string Temp in ArrCompnay)
{
if (Temp== dsCompany.Tables[0].Rows[i][0].ToString())
{
strCompany.Append(" checked");
break;
}
}
}
catch
{}
}

strCompany.Append("
onClick='foo(this.value,this.checked);document.for ms[0].submit()'
name='chkCompany' id='chkCompany' value='" +
dsCompany.Tables[0].Rows[i][0].ToString() + "'>" +
dsCompany.Tables[0].Rows[i][1].ToString());
SqlCommand objcomm2 =new SqlCommand();
try
{
objcomm2.CommandText="Usp_LeftMenu_Contact";
objcomm2.Connection=con;
objcomm2.CommandType = CommandType.StoredProcedure;
objcomm2.Parameters.Clear();
objcomm2.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm2.Parameters.Add( "@SESSION_USERID", userid );
objcomm2.Parameters.Add( "@permission", permission );

objcomm2.Parameters.Add(
"@FILTER_ROLEID",Session["Filterroleid"]);
objcomm2.Parameters.Add(
"@FILTER_USERID",Session["Filteruserid"]);
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm2.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"]);
objcomm2.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"]);
objcomm2.Parameters.Add(
"@FILTER_CONTACTCOMPANYID",dsCompany.Tables[0].Rows[i][0].ToString());

daContact.SelectCommand=objcomm2;
daContact.Fill(dsContact);

}
finally
{
daContact.Dispose();
objcomm2.Dispose();
}

if (dsContact.Tables[0].Rows.Count>0)
{
for (int j=0;j<dsContact.Tables[0].Rows.Count;j++)
{
strCompany.Append("<br>");
strCompany.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;<input
type=checkbox ");
if(HdnSelectClear.Value=="1")
{
strCompany.Append(" checked");
Session["SelectedContact"]=Session["SelectedContact"]+","+
dsContact.Tables[0].Rows[j][0].ToString();
}
else if(HdnSelectClear.Value=="0")
{
Session["SelectedCompany"]="";
}
else if(CompanyID.Value!="" &&
dsCompany.Tables[0].Rows[i][0].ToString()==CompanyID.Value)
{

if(Convert.ToBoolean(CheckBoxFlag.Value))
{
strCompany.Append(" checked");

Session["SelectedContact"]=Session["SelectedContact"]+","+
dsContact.Tables[0].Rows[j][0].ToString();
}
}
else
{
try
{
string [] ArrContacts=Request.Form["chkContact"].Split(new
char[] {','});

foreach ( string Temp in ArrContacts)
{
if (Temp== dsContact.Tables[0].Rows[j][0].ToString())
{
strCompany.Append(" checked");
Session["SelectedContact"]=Session["SelectedContact"]+","+dsContact.Tables[0].Rows[j][0].ToString();
break;
}
}
}
catch
{}
}
strCompany.Append(" onClick='document.forms[0].submit()'
name='chkContact' id='chkContact' value='" +
dsContact.Tables[0].Rows[j][0].ToString() + "'>" +"<span
class=FilterListContact>"+
dsContact.Tables[0].Rows[j][1].ToString()+"</span>");
// strCompany.Append("
onClick='document.forms[0].submit()' name='chkContact' id='chkContact'
value='" + dsContact.Tables[0].Rows[j][0].ToString() + "'>" +
dsContact.Tables[0].Rows[j][1].ToString());
}

if(CompanyID.Value!="" &&
dsCompany.Tables[0].Rows[i][0].ToString()==CompanyID.Value)
{
CompanyID.Value="";
}
}
HTMLString=strCompany.ToString();
try
{
if(Session["SelectedContact"].ToString().StartsWith(","))
{
Session["SelectedContact"]=Session["SelectedContact"].ToString().Substring(1,Session["SelectedContact"].ToString().Length-1);
}
}
catch{}
}
try
{
if(Session["SelectedCompany"].ToString().StartsWith(","))
{
Session["SelectedCompany"]=Session["SelectedCompany"].ToString().Substring(1,Session["SelectedCompany"].ToString().Length-1);
}
}
catch{}
if(HdnSelectClear.Value!="")
{
HdnSelectClear.Value="";
}

}
}

Regards
Amit Arora

Apr 16 '06 #3

P: n/a
string roleid = Session["RoleID"].ToString();
string userid = Session["UserID"].ToString();

how are you filling those session variables? Are they filled from a global
source? If yes, is that source protected against concurrency?

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

<ar*********@gmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
Well when I run my code seprately in dummy project it works fine, but
when I integrate the same in my project it gives me problem......
Well this code executes in separate Left Frame.......

Another thing which comes to my mind is in dummy project I just execute
simple queries but in my original project I use two stored procedures,
can something wrong be here in procedures itself.
Well here goes my code..............

public void GetCompanyContact()
{
string roleid = Session["RoleID"].ToString();
string userid = Session["UserID"].ToString();

SqlConnection con = new
SqlConnection(ConfigurationSettings.AppSettings["CMSConnection"]);
SqlCommand objcomm = new SqlCommand();
DataSet dsCompany=new DataSet();
SqlDataAdapter daCompany = new SqlDataAdapter();
SqlDataAdapter daContact = new SqlDataAdapter();

CommonRules.CommonLogic cmLogic=new CMS.CommonRules.CommonLogic();

int permission=0;
if((cmLogic.isValidServiceItem(Convert.ToInt32(Ses sion["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
try
{
con.Open();
objcomm.CommandText="Usp_LeftMenu_Company";
objcomm.Connection=con;

objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );

objcomm.Parameters.Add(
"@FILTER_ROLEID",Convert.ToInt32(Session["Filterroleid"]));
objcomm.Parameters.Add(
"@FILTER_USERID",Convert.ToInt32(Session["Filteruserid"]));
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Convert.ToInt32(Session["FilterIV"]));
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Convert.ToInt32(Session["FilterDomain"]));
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Convert.ToInt32(Session["FilterSource"]));
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Convert.ToInt32(Session["FilterWorkType"]));
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Convert.ToInt32(Sessio n["FilterDisposition"]));
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"].ToString());
objcomm.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"].ToString());
objcomm.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"].ToString());
daCompany.SelectCommand=objcomm;
daCompany.Fill(dsCompany);

}
finally
{
objcomm.Dispose();
daCompany.Dispose();

}
Session["SelectedContact"]="";

System.Text.StringBuilder strCompany=new
System.Text.StringBuilder();
if (dsCompany.Tables[0].Rows.Count>0)
{
for (int i=0;i<dsCompany.Tables[0].Rows.Count;i++)
{
strCompany.Append("<br>&nbsp;&nbsp;");
strCompany.Append("<input type=checkbox ");
DataSet dsContact =new DataSet();
if(HdnSelectClear.Value=="1")
{
strCompany.Append(" checked");
Session["SelectedCompany"]=Session["SelectedCompany"]+","+
dsCompany.Tables[0].Rows[i][0].ToString();
}
else if(HdnSelectClear.Value=="0")
{
Session["SelectedCompany"]="";
}
else
{
try
{
string [] ArrCompnay=Request.Form["chkCompany"].Split(new char[]
{','});
foreach (string Temp in ArrCompnay)
{
if (Temp== dsCompany.Tables[0].Rows[i][0].ToString())
{
strCompany.Append(" checked");
break;
}
}
}
catch
{}
}

strCompany.Append("
onClick='foo(this.value,this.checked);document.for ms[0].submit()'
name='chkCompany' id='chkCompany' value='" +
dsCompany.Tables[0].Rows[i][0].ToString() + "'>" +
dsCompany.Tables[0].Rows[i][1].ToString());
SqlCommand objcomm2 =new SqlCommand();
try
{
objcomm2.CommandText="Usp_LeftMenu_Contact";
objcomm2.Connection=con;
objcomm2.CommandType = CommandType.StoredProcedure;
objcomm2.Parameters.Clear();
objcomm2.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm2.Parameters.Add( "@SESSION_USERID", userid );
objcomm2.Parameters.Add( "@permission", permission );

objcomm2.Parameters.Add(
"@FILTER_ROLEID",Session["Filterroleid"]);
objcomm2.Parameters.Add(
"@FILTER_USERID",Session["Filteruserid"]);
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm2.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"]);
objcomm2.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"]);
objcomm2.Parameters.Add(
"@FILTER_CONTACTCOMPANYID",dsCompany.Tables[0].Rows[i][0].ToString());

daContact.SelectCommand=objcomm2;
daContact.Fill(dsContact);

}
finally
{
daContact.Dispose();
objcomm2.Dispose();
}

if (dsContact.Tables[0].Rows.Count>0)
{
for (int j=0;j<dsContact.Tables[0].Rows.Count;j++)
{
strCompany.Append("<br>");
strCompany.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;<input
type=checkbox ");
if(HdnSelectClear.Value=="1")
{
strCompany.Append(" checked");
Session["SelectedContact"]=Session["SelectedContact"]+","+
dsContact.Tables[0].Rows[j][0].ToString();
}
else if(HdnSelectClear.Value=="0")
{
Session["SelectedCompany"]="";
}
else if(CompanyID.Value!="" &&
dsCompany.Tables[0].Rows[i][0].ToString()==CompanyID.Value)
{

if(Convert.ToBoolean(CheckBoxFlag.Value))
{
strCompany.Append(" checked");

Session["SelectedContact"]=Session["SelectedContact"]+","+
dsContact.Tables[0].Rows[j][0].ToString();
}
}
else
{
try
{
string [] ArrContacts=Request.Form["chkContact"].Split(new
char[] {','});

foreach ( string Temp in ArrContacts)
{
if (Temp== dsContact.Tables[0].Rows[j][0].ToString())
{
strCompany.Append(" checked");
Session["SelectedContact"]=Session["SelectedContact"]+","+dsContact.Tables[0].Rows[j][0].ToString();
break;
}
}
}
catch
{}
}
strCompany.Append(" onClick='document.forms[0].submit()'
name='chkContact' id='chkContact' value='" +
dsContact.Tables[0].Rows[j][0].ToString() + "'>" +"<span
class=FilterListContact>"+
dsContact.Tables[0].Rows[j][1].ToString()+"</span>");
// strCompany.Append("
onClick='document.forms[0].submit()' name='chkContact' id='chkContact'
value='" + dsContact.Tables[0].Rows[j][0].ToString() + "'>" +
dsContact.Tables[0].Rows[j][1].ToString());
}

if(CompanyID.Value!="" &&
dsCompany.Tables[0].Rows[i][0].ToString()==CompanyID.Value)
{
CompanyID.Value="";
}
}
HTMLString=strCompany.ToString();
try
{
if(Session["SelectedContact"].ToString().StartsWith(","))
{
Session["SelectedContact"]=Session["SelectedContact"].ToString().Substring(1,Session["SelectedContact"].ToString().Length-1);
}
}
catch{}
}
try
{
if(Session["SelectedCompany"].ToString().StartsWith(","))
{
Session["SelectedCompany"]=Session["SelectedCompany"].ToString().Substring(1,Session["SelectedCompany"].ToString().Length-1);
}
}
catch{}
if(HdnSelectClear.Value!="")
{
HdnSelectClear.Value="";
}

}
}

Regards
Amit Arora

Apr 16 '06 #4

P: n/a
These are filled up at the time of login................. And how do I
make sure to protect it against concurrency........

If the problem is really here then why my SessionID gets dumped to
other user..........

Regards,
Amit Arora

Apr 17 '06 #5

P: n/a
This duplicates thread
http://groups.google.com/group/micro...b831750422bdf9
yet it appears you've tried none of the suggestions in that thread,
such as manually testing your stored procedures or simplifying your
code samples.

Reposting to get an answer you like better wastes all our time.

Apr 17 '06 #6

P: n/a
good cache russell. I'm done here.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

"Russell" <ru*****@goisc.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
This duplicates thread
http://groups.google.com/group/micro...b831750422bdf9
yet it appears you've tried none of the suggestions in that thread,
such as manually testing your stored procedures or simplifying your
code samples.

Reposting to get an answer you like better wastes all our time.

Apr 17 '06 #7

P: n/a
Well Buddy, I tried everything................. Including testing of
stored procedure. I even rewritten the code there. But nothing worked
for me........... As far as wasting the time is concerned I never
intend so..........
Anyways good news is that my problem has been solved....

Thanks for your sincere efforts..........

Reagrds,
Amit Arora

Apr 18 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.