i v stored some database driven values into session variables at the time of login(i.e user id,user name cetc..)..while running this website in localhost(iis)this works fine. but while i upload this in windows webserver without giving ne error it seems that
session variables failed to store the data(after logging in while navigating through the website session variables become null).but the confusing thing is that somtimes itz working..
If the windows "web server" you are uploading to is a web farm (collection of servers) you cannot use sessionState mode. The first time a client hits the site, it may go to Server A and store the session variable. The second time the client hits the site,
it may go to Server B where it will not find the session variable.
By the way, failing silently is not a good idea. And, you should close the connection in the finally clause:
I have just recently started having the same problem. Actually I'm not sure how long it's been happening, but users are starting to report the problem more frequently now. It seems to be very sporadic and I cannot replicate it. My website flow is pretty
similar to yours. I run a database query, present the results to the user, and the user selects one of the options. The data is moved via query string to another page where they log in. After login a database row is created and the data is stored in the
database. The user gets back an id corresponding to the database row. That id is stored into session variables. Every now and again it appears that my session variables become null. I have no idea what is causing the problem and the fact that I can't replicate
makes it very difficult to troubleshoot. I hope someone can shed some light!
I am also having this same problem. Please post if anyone have any answer.
Thanks
jijo
Hi,
as was stated on previous post. InProc session will be lost when AppDomain restarts occurs. Reason for that could be change in web.config, change of dlls in bin directory, virus scanner touching global.asax, application pool restarts (Windows Server 2003 /
Vista), or application hangup whatever which forces it to be restarted. Therefore it's always more durable to keep the session in separate process (StateServer) or SQl Server. This way no restarts whatsoever interfere the sessions.
shuvradip
Member
10 Points
9 Posts
SESSION VARIABLE NOT WORKING IN WEB SERVER
Aug 07, 2007 08:03 AM|LINK
i v stored some database driven values into session variables at the time of login(i.e user id,user name cetc..)..while running this website in localhost(iis)this works fine. but while i upload this in windows webserver without giving ne error it seems that session variables failed to store the data(after logging in while navigating through the website session variables become null).but the confusing thing is that somtimes itz working..
sessionState mode is default for windows server
please help
following is the code
string sSqlCmd = "SELECT eum_id, eum_uid, eum_pwd, eum_name, edm_name, eum_evm_id,eum_edm_id FROM ei_user_master,ei_dealer_master where eum_edm_id = " + ddlDealer.SelectedValue + " and eum_uid = '" + txtUser.Text + "' and eum_evm_id = " + cmbDept.SelectedValue + "";
// Open the database
conn.Open();
OleDbDataReader dr;
OleDbCommand cmd = new OleDbCommand(sSqlCmd, conn);
dr = cmd.ExecuteReader();
dr.Read();
if (!dr.HasRows)
{
FailureText.Text = "invalid username/dealer of/dealer name";
conn.Close();
}
else
{
if (dr["eum_pwd"].ToString() != txtPwd.Text)
{
FailureText.Text = "invalid password";
conn.Close();
}
else
{
try
{
Session["UidER"] = dr["eum_id"];
Session["UserName"] = dr["eum_name"];
Session["DealerName"] = dr["edm_name"];
Session["VehicleID"] = dr["eum_evm_id"];
Session["DealerID"] = dr["eum_edm_id"];
conn.Close();
}
catch (Exception ex)
{
}
finally
{
Response.Redirect("Configuration.aspx");
}
}
}
please help
Session asp.net 2.0 session start Session Management authentication asp.net c# session state management
software developer
xinis pvt ltd.,Kolkata
SGWellens
All-Star
126031 Points
10310 Posts
Moderator
Re: SESSION VARIABLE NOT WORKING IN WEB SERVER
Aug 07, 2007 11:22 AM|LINK
If the windows "web server" you are uploading to is a web farm (collection of servers) you cannot use sessionState mode. The first time a client hits the site, it may go to Server A and store the session variable. The second time the client hits the site, it may go to Server B where it will not find the session variable.
By the way, failing silently is not a good idea. And, you should close the connection in the finally clause:
catch (Exception ex) { // report something! } finally { conn.Close(); Response.Redirect("Configuration.aspx"); }My blog
shuvradip
Member
10 Points
9 Posts
Re: SESSION VARIABLE NOT WORKING IN WEB SERVER
Aug 07, 2007 11:45 AM|LINK
thanks sir
in the finally clause conn.close is der please tell me if that ll nt work .
my sessionState mode is "inproc"(by default) and the web server is not distributed
software developer
xinis pvt ltd.,Kolkata
shu_chen4
Member
2 Points
1 Post
Re: SESSION VARIABLE NOT WORKING IN WEB SERVER
Aug 10, 2007 03:19 AM|LINK
I have just recently started having the same problem. Actually I'm not sure how long it's been happening, but users are starting to report the problem more frequently now. It seems to be very sporadic and I cannot replicate it. My website flow is pretty similar to yours. I run a database query, present the results to the user, and the user selects one of the options. The data is moved via query string to another page where they log in. After login a database row is created and the data is stored in the database. The user gets back an id corresponding to the database row. That id is stored into session variables. Every now and again it appears that my session variables become null. I have no idea what is causing the problem and the fact that I can't replicate makes it very difficult to troubleshoot. I hope someone can shed some light!
gursharnsing...
Participant
884 Points
125 Posts
Re: SESSION VARIABLE NOT WORKING IN WEB SERVER
Aug 11, 2007 07:22 PM|LINK
asp worker process that handles aspx requests in InProc mode could be restarted to improve performance or due to system restart.
You should use StateServer or SqlServer session management if you want to preserve session state.
[Don't forget to click on Mark As Answer on the post that helped you ]
jijo_robert
Member
436 Points
124 Posts
Re: SESSION VARIABLE NOT WORKING IN WEB SERVER
Aug 11, 2007 09:07 PM|LINK
I am also having this same problem. Please post if anyone have any answer.
Thanks
jijo
joteke
All-Star
46284 Points
6896 Posts
ASPInsiders
MVP
Re: SESSION VARIABLE NOT WORKING IN WEB SERVER
Aug 12, 2007 09:36 AM|LINK
Hi,
as was stated on previous post. InProc session will be lost when AppDomain restarts occurs. Reason for that could be change in web.config, change of dlls in bin directory, virus scanner touching global.asax, application pool restarts (Windows Server 2003 / Vista), or application hangup whatever which forces it to be restarted. Therefore it's always more durable to keep the session in separate process (StateServer) or SQl Server. This way no restarts whatsoever interfere the sessions.
More information about session state modes: http://msdn2.microsoft.com/en-us/library/ms178586.aspx
Teemu Keiski
Finland, EU