Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void Page_Load(object sender, EventArgs e)
        {
             if (!IsPostBack)
                {
                     try
                    {

                    if (Session["username"] != null)
                   {

                        lblUserName.Text = Session["username"].ToString();
                        lblTodayDate.Text = DateTime.Today.Date.ToString();
                    }

                    else
                    {
                        Response.Redirect("~/SessionExpired.aspx");
                    }

                     }


                catch (Exception exp)
                 {
                    WebFormMaster.WriteToErrorLog("", exp);
                 }
                }
        }





when i was run this code in my local system it is working successfull, but when i was hosted this code in server some times it shows session experied, but i gave session timeout is 60 minuts, can any body suggest me.


it shows error message like this:

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.AbortCurrentThread()
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)
at SFISSPACE.Admin_AdminMaster.Page_Load(Object sender, EventArgs e)


[Edit]:
Posted
Updated 3-Oct-13 18:50pm
v3
Comments
Dholakiya Ankit 3-Oct-13 8:28am    
Where you give ? session timeout value
Member 10042721 3-Oct-13 8:36am    
at web.config
sessionState timeout="60" mode="InProc"/>
Dholakiya Ankit 4-Oct-13 0:08am    
Make sure that enablesessionstate=true

Hi,
actually incorrect session timeout setting by you in web.config file means if you want to set it as 60 minutes then you have to enter timeout period in miliseconds in session timeout property of webconfig. that means if you want to set it 1 minutes then you have to enter value - 1000
as :
sessionstate timeout="1000"
 
Share this answer
 
v2
use this
C#
Response.Redirect("~/SessionExpired.aspx", false);
Context.ApplicationInstance.CompleteRequest();

instead of
C#
Response.Redirect("~/SessionExpired.aspx");
 
Share this answer
 

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