Session timeout

Last post 07-07-2009 4:29 AM by sirdneo. 4 replies.

Sort Posts:

  • Session timeout

    07-03-2009, 6:24 AM
    • Member
      19 point Member
    • Lasar
    • Member since 05-28-2009, 3:19 PM
    • Posts 28

    I am developing a site in DNN platform. In my site(as shopping cart), I am using session.

         But, I am loosing my session within 2 to 3 minutes. I have made neccessary changes in my web config. 

         Code I added in web config.

                         <sessionState
                          mode="InProc"
                          stateNetworkTimeout="10000"
                          stateConnectionString="tcpip=127.0.0.1:42424"
                          sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
                         cookieless="false"
                         timeout="10000"
                       />

          I want my session to be alive for more than 45 to 60 minutes.

          Is any thing want to add in the web config.

         Please help me.

         Thank You..........

  • Re: Session timeout

    07-03-2009, 7:41 AM
    Answer
    • Member
      660 point Member
    • avicool08
    • Member since 04-28-2008, 7:25 AM
    • Bangalore
    • Posts 246

     ok now,

    May be this is hapening because of internal error occured in your project....

    In my website(not DNN), what i did is I wrote a application_error event, which will fire, if any where in the project error occurs and write to a log file, and here is the code below, try to handel the error....(not sure about the code will be same in DNN or not, just check once)

    void Application_Error(object sender, EventArgs e) 
        {
    
            // Code that runs when an unhandled error occurs
            try
            {
    
    
                //if (Server.GetLastError().GetType() == typeof(HttpException))
                //{
                if (!Server.GetLastError().Message.Trim().Contains("File does not exist."))
                {
                    Session["UserID"] = null;
                    Session.Abandon();
                    Session.Clear();
                    Response.Expires = 0;
                    Response.Cache.SetNoStore();
                    Response.AppendHeader("Pragma", "no-cache");
                    Response.Clear();
    
                    HttpApplication app = (HttpApplication)sender;
                    HttpContext context = app.Context;
                    Exception ex = context.Server.GetLastError().GetBaseException();
                    context.Response.Clear();
                    ExceptionUtility.LogException(ex, "Global.asax", "Application_Error");
                }
                //}
    
            }
            catch (Exception ex)
            {
                string strErro = ex.Message;
            }
        }


     

    Regards
    Avinash



    Please mark my reply as an
    answer
    if it helps.

    Visit my blog .net Scanner
  • Re: Session timeout

    07-03-2009, 8:42 AM
    • Contributor
      2,466 point Contributor
    • SSA
    • Member since 05-07-2009, 7:16 PM
    • Amsterdam, The Nederlands
    • Posts 407

    Hi Lasar,

    http://forums.asp.net/p/1350386/2755959.aspx 

    This explains why it expires, but I would like to know are you using login web control? I had the same problem.

    then try this:

    <authentication mode="Forms">
    <forms loginUrl="~/Modules/Authentication/Login.aspx" protection="All" timeout="30" name=".ShopperASPXAUTH" path="~" requireSSL="false" slidingExpiration="true" defaultUrl="default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false"/>
    </authentication>

    <authentication mode="Forms">

    <forms loginUrl="~/Modules/Authentication/Login.aspx" protection="All" timeout="30" name=".ASPXAUTH" path="~" requireSSL="false" slidingExpiration="true" defaultUrl="default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false"/>

    </authentication>

    Note there is seperate setting on IIS for session timeout.

  • Re: Session timeout

    07-04-2009, 12:51 AM
    • Member
      315 point Member
    • sureshmdb
    • Member since 05-27-2008, 12:18 PM
    • Baleru
    • Posts 61

     Hi Lasar,

              So many causes for Session Timeout,some of them you checked in web.config file and coding part.Is it working fine in your local system(ie in local system you didn't face the session out problem) then it means Serverpeople are restricted to your application due to causes fo logfiles so you clear the log files of SQL server

    Suresh Mediboyina



    Mark as answer if my response is useful to you.
  • Re: Session timeout

    07-07-2009, 4:29 AM
    Answer
    • Contributor
      7,238 point Contributor
    • sirdneo
    • Member since 12-16-2008, 12:45 AM
    • Karachi, Pakistan
    • Posts 1,137

    There are a lot of reasons for session loss. To name a few,

    1-  Application Pool is recycled. - We will know this looking at the system logs
    2-  IIS/worker process is restarted. - System logs will tell this as well
    3-  Application Domain is restarted. - We need to monitor for application restarts for the ASP.NET counter in perfmon to check this.

    Few reasons for application restarts include
    1- Bin folder of the application is touched by some application (Might Be antivirus)
    2- Web.config or the machine.config is touched (Might Be antivirus)
    3- Global.asax file is touched (Might Be antivirus)
    4- Antivirus is running
    5- Something in the code is causing session loss, it can be anything. You will need to look into the code to have a fix on this.
    6- Any Other thing :(

    If all mentioned above did not help you then it might be due to anti virus software. Software scans the files in application folder and updates their date/time. Which causes IIS to restart. There fore uninstall the anti virus from server. However, if you exclude the application folder from virus scan that will also do the job. Also you need to remove .config,.aspx,.ascs and other extensions specific to your application for further security.

    Thanks,
    Zeeshan Umar

    ~Please Mark As Answer, if one or multiple posts, which helped you in your problem. So that it might be useful for others~

    My Blog
Page 1 of 1 (5 items)