This project has moved and is read-only. For the latest updates, please go here.

Issue when accessing asp page on first request

Nov 6, 2014 at 4:49 PM
Hi,
I have an issue when accessing the session service from an asp page as the first request. This only happens if this is a new session and I have cleared my cookies. I have a SessionModule defined as per the example on this site. The ApplicationBeginRequest works fine.
    private void ApplicationBeginRequest(object source, EventArgs e)
    {
        var application = (HttpApplication)source;
        HttpContext context = application.Context;

        if (this.IsSessionRequest(context))
        {
            AspSession aspSession = new AspSession(context);
            if (aspSession.Contents.Count <= 0)
            {
                InitSession(aspSession);
            }
            context.Items["HomelidaysAspSession"] = aspSession;
        }
    }
The ApplicationEndRequest returns the AspSession object fine, but the Contents contain an exception due to the sessionid containing a ;path=/ appended to the end. It is a different session id than the BeginRequest, though it is the same request. If I hit a Controller first, it works fine, sessionID saved, etc.

The exception is:

Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Source Error:


Line 78: {
Line 79: // A l'unload de la page on fait la persistence de la session en base
Line 80: aspSession.PersistSession();
Line 81: }
Line 82: }


Source File: c:\Users\gtibbitts\Source\Repos\ZionsFX3\ZionsFx\SharedLib\SessionModule.cs Line: 80

Stack Trace:


[FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).]
System.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException) +4928304
System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result) +96
System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result) +637
System.Guid..ctor(String g) +247
Homelidays.Web.SessionService.AspSessionPersistence.RefreshSession(String sessionId) +360
Homelidays.Web.SessionService.AspSession.PersistSession() +219
ZionsFx.SessionModule.ApplicationEndRequest(Object source, EventArgs e) in c:\Users\gtibbitts\Source\Repos\ZionsFX3\ZionsFx\SharedLib\SessionModule.cs:80
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

Thanks for your help on this.
Coordinator
Nov 7, 2014 at 2:29 PM
Hello,

Thank you for reporting this.
I will try to have a look on your issue this week-end and come back to you.

Yanal
Coordinator
Nov 7, 2014 at 2:41 PM
Hello,
  1. Could you share with me your session module?
  2. To help you the quickest, the best would be if you can create a new solution with a new web app. Inject your module in it and reproduce the issue outside your existing app and send it to me.
Else I can try but I am not sure I will be able to reproduce your issue.

I will support you
Yanal
Coordinator
Nov 10, 2014 at 9:45 AM
Edited Nov 10, 2014 at 9:46 AM
Hello,

Any news ?

I am trying to reproduce your issue now by follwowing on an empty web site the steps described here: https://sessionservice.codeplex.com/wikipage?title=Use%20the%20session%20service%20in%20ASP.NET%20code.
I am updating the wiki page every time I am seeing some mistakes.

I am confident that this bug should not happend if you configured it correctly.
This code has been used in high production volume (up to 1200 hits per second for hours) for years on www.homelidays.com without any issue.

On the wiki page mentioned above they were initially only the section that explain how to use it on ASP.NET Web Form.
I added the module section later when somebody asked me how to use it with ASP.NET MVC.
So now I feel the page is pretty confusing.
If you implemented the module (solution used at Homeidays) you don't need any code behind in ASP.NET WEB Form page.
The module solution works for both ASP.NET MVC and ASP.NET Web Forms.

I will continue to follow steps and update the wiki page.

Yanal
Coordinator
Nov 10, 2014 at 12:17 PM
Hello,

I wasn't able this morning (Paris time) to reproduce your issue.

I started from a computer where the Homelidays Session Service has never been installed.

I followed (and updated):
  1. https://sessionservice.codeplex.com/wikipage?title=Install%20the%20Homelidays%20Session%20Service
  2. https://sessionservice.codeplex.com/wikipage?title=Use%20the%20session%20service%20in%20ASP.NET%20code
Please find here the resulting code: https://github.com/Yanal-Yves/HomelidaysSessionServiceDemo

Could you reproduce the issue within the HomelidaysSessionServiceDemo ?

Yanal