tags:

views:

30

answers:

1

Hello all,

I've a Web App that just recently has began randomly losing sessions. The exact cause is elusive at best, however it seems the session is killed/lost on the server side and results in the user needing to close their browser entirely and relaunch in order to log back in.

I wish I could provide some code, but I can't figure out where the problem is at all.

Here is a session action filter we use currently:

public class SessionExpireAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        HttpContext lvContext = HttpContext.Current;

        //if(

        // check if session is supported   
        if (lvContext.Session != null)
        {

            // check if a new session id was generated   
            if (lvContext.Session.IsNewSession)
            {

                // If it says it is a new session, but an existing cookie exists, then it must   
                // have timed out   
                string sessionCookie = lvContext.Request.Headers["Cookie"];
                if ((null != sessionCookie) && (sessionCookie.IndexOf("ASP.NET_SessionId") >= 0))
                {

                    lvContext.Response.Redirect("~/Account/Timeout");
                }
            }
        }


        base.OnActionExecuting(filterContext);
    }
}
A: 

Did you add a new feature that adds or removes files from the root directory or any of its subdirectories? That can cause the session to reset.

Cristi Todoran
AFAIK it's only folder deletes that cause this, adding and deleting files should be fine, unless you're adding and deleting them from the /bin and /App_Data folder. Also programmatically modifying the Web.config file can cause App Domain restarts. Check that your code isn't doing any of these things anywhere. If folder deletes is an issue, let me know, I know of a work around.
Sunday Ironfoot
I did recently add two web-based image editors, however they only add/delete a temporary tiff file. The Web.config is never programmatically or manually altered unless we're releasing a new revision.
alan
The temporary solution was to recycle the App Pool after every 100 calls. This has significantly reduced our incident rate.
alan