Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends ,
I Made a web application in which i have one login page after successful login session value is set like
Session["user"]=txtusername.Text;

Then I have one master page On which i am checking the session value i.e.
C#
if (Session["user"] == null)
        {
            Session.Abandon();
            Response.Redirect("Login_Master.aspx");
        }

then i have one other form for data entry which is basicaaly the child page of master page when i click one save but after filling all the required field it somtimes redirect to login page with out saving data and somtime it save.
this application is working when hosted or debug locally but this problem arises when it hosted on web server remotely.
coding for data entry page is shown below :
C#
string accname = ddlaccname.SelectedValue.ToString();
                   string accman = ddlaccmanager.SelectedValue.ToString();
                   string currentdate = DateTime.Now.ToString("dd/MM/yyyy");
                   //string product = ddlproduct.SelectedValue.ToString();
                   string[] products = new string[ListBox1.Items.Count];

                   string[] productsname = new string[ListBox1.Items.Count];
                   int progress = Convert.ToInt32(ddlprogress.SelectedValue.ToString());
                   for (int i = 0; i < ListBox1.Items.Count; i++)
                   {
                       products[i] = ListBox1.Items[i].Value.ToString();
                       productsname[i] = ListBox1.Items[i].ToString();
                   }
                   string emp_id = Session["emp_id"].ToString();
                 
                     string insert="insert query  for data inserion";
                    string insert1="insert query 1 for data inserion";

                   SqlTransaction st;
                   con.Open();
                   st = con.BeginTransaction();
                   try
                   {
                       new SqlCommand(insert, con, st).ExecuteNonQuery();


                       new SqlCommand(insert1, con, st).ExecuteNonQuery();


                       for (int j = 0; j < ListBox1.Items.Count; j++)
                       {
                           string insert3="insert query 3 for data inserion";
                           new SqlCommand(insert3, con, st).ExecuteNonQuery();
                       }
                       st.Commit();
                       con.Close();
                        //SendMail();
                       Response.Redirect("LEAD_MASTER.aspx");
                       //Response.Redirect("LEAD_MASTER.aspx",



I don't know what is the main problem please suggest some solution for that my session timeout by default is set to 1Hour which is not a problem .
Posted
Comments
sjelen 25-Apr-12 7:58am    
What type of session do you use? in-proc, state server or SQL?
If you use in-proc (default) you're probably loosing session due to application restart/appdomain recycle.
advancedansh 25-Apr-12 8:15am    
i am using default session
Vipin_Arora 1-May-12 1:53am    
Hi danish,
Is your problem resolved?
advancedansh 1-May-12 2:00am    
Hoping that it should be resolved soon i had talk to my hosting server provider and ask to check the system log .

 
Share this answer
 
v2
Comments
advancedansh 25-Apr-12 7:24am    
Thanks for your replay sir but i already said above that the defalut session time is 1 hour so you 2 link is not suited for me.
advancedansh 25-Apr-12 7:30am    
the global.asax file code is show below

<%@ Application Language="C#" %>

<script runat="server">

void Application_Start(object sender, EventArgs e)
{
Application["users"] = 0;

}

void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown

}

void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs

}

void Session_Start(object sender, EventArgs e)
{
int i = (int)Application["users"];
i = i + 1;
Application["users"] = i;

}

void Session_End(object sender, EventArgs e)
{
int i = (int)Application["users"];
i = i - 1;
Application["users"] = i;

}

</script>
please chech is effect something
Vipin_Arora 25-Apr-12 7:32am    
are you using any UpdatePanel on your page or you are using any Link with "http://" in your code file??
advancedansh 25-Apr-12 7:33am    
No in starting i use ajax but now i remove ajax control so no update panel was usedand i dont use any http link sir
Vipin_Arora 25-Apr-12 7:42am    
Ok..then Go to your IIS->AppPool("Default Website" in case you didnt create any Pool)->Advance Settings->ConnectionLimits->ConnectionTimout..
Check the value..if it is too low then, set it to around 120 seconds
hi,

1)Make sure that you are checking the session like HttpContext.Current.Session("")

2) Check with your host about the setting of IIS hosting your app. May be the IIS is reset frequently or the app pool in which your app is being recycled frequently.

best luck
 
Share this answer
 
Comments
advancedansh 25-Apr-12 7:35am    
sir i want some detail about 2 point i have no idea about this please let me clear it pls
i think it will be problem on your server.Try with somewhere else!! and are you getting same problem again ?
 
Share this answer
 
Comments
advancedansh 25-Apr-12 7:27am    
yes i checked it locally it working fine .but when i published on internet it shows problem i want to ask one thing that is that problem will relate to response.redirect() or server.transfer() is this are two method will effect session values.
Anuj Banka 25-Apr-12 7:30am    
no that is not the problem.Check on some other server.It is problem Of IIS i think.something is cooking on server.So you can try on other server.
advancedansh 25-Apr-12 7:32am    
yes i already try on my local intanet and also on my iss it working fine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900