Hybrid View

  1. #1
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    941
    Vote Rating
    66
    westy is just really nice westy is just really nice westy is just really nice westy is just really nice

      0  

    Default Ext.Direct and HTTP sessions

    Ext.Direct and HTTP sessions


    Hi,

    I hope I'm going mad, but I suspect not.

    I'm calling Ext.Direct methods, and getting different session ids each time!

    Using IIS7, and a tweaked version of Evan's Ext.Direct router.
    Each action class implements IReadOnlySessionState.

    Server-side (simplifed):
    Code:
    [DirectAction()]
    public class MyHandler : DirectHandler, IReadOnlySessionState
    {
        [DirectMethod("getSessionId")]
        public string GetSessionId()
        {
            return HttpContext.Current.Session.SessionID;
        }
    }
    Client-side:
    Code:
                var repeatCount = 20;
    
                var func = function(counter) {
                    MyHandler.getSessionId(
                        function(response, e) {
                            if (e.status) {
                                me.update(Ext.String.format('{0}<br/>SessionId{1}: {2}', me.html, counter, Ext.isEmpty(response) ? '<empty>' : response));
                            } else {
                                me.update(Ext.String.format('{0}<br/>Exception{1}: {2}', me.html, counter, e.message));
                            }
    
                            if (counter < repeatCount) {
                                func(++counter);
                            }
                        }
                    );
                }
    
                func(1);
    Output:
    Code:
    SessionId1: rbfqlb55iyowcp45oly11w55
    SessionId2: cy0gwvu0sivxax555jochdfm
    SessionId3: mmxizyia2crhla45aowtf4ft
    SessionId4: y5lqv345m2fanp554v0batrf
    SessionId5: cshgms5503i4hs55yzi0t155
    SessionId6: zwmaxfjvu2qkueuxpds1bem4
    SessionId7: vxwh2dynkdwpkeyt3e5j4y45
    SessionId8: omsbawv042eju155ebt2gr2i
    SessionId9: dsa31dz5eys2gd45qrmtmn55
    SessionId10: 3ac1lv55te0odk55ii0poz45
    SessionId11: sekf1w452rzbq52zji4hrn45
    SessionId12: trabhsugqt3rsf55w55arn2s
    SessionId13: z4tk1y3wiqonftejpa0nddri
    SessionId14: cq1vqaznudfclq553q10syq1
    SessionId15: ksylrcawjx23j3555es3qrnq
    SessionId16: oiju1h452uywvy45cecju245
    SessionId17: lkfljwnk0rvgt52f1ikemorm
    SessionId18: a453sinrbasaws55yiwbc545
    SessionId19: fghs0p55zymu1vywh4vg5a55
    SessionId20: j0sa05efxicc40bo3qwoyl2y
    Am I missing something?

    Please help, session data is crucial to our authentication mechanism!

    Cheers,
    Westy

  2. #2
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    941
    Vote Rating
    66
    westy is just really nice westy is just really nice westy is just really nice westy is just really nice

      0  

    Default


    Hmm, from extensive googling it seems that all calls to a IHttpHandler get a new session.

    There must be a way around this!

  3. #3
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    941
    Vote Rating
    66
    westy is just really nice westy is just really nice westy is just really nice westy is just really nice

      0  

    Default


    Can't help think that it's something to do with the ASP.NET_SessionId cookie.

    Does Ext store the session id returned by the server, and pass it back in with subsequent requests?

    Does the same thing happen with standard Ajax requests (that'll be my next test I think)?
    It certainly didn't when I used Ext 2 and standard HTTP post/get asmx web services or JayRock services.

  4. #4
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    941
    Vote Rating
    66
    westy is just really nice westy is just really nice westy is just really nice westy is just really nice

      0  

    Default


    Seems that response cookie is set to pass back the aspnet session but something is then striping it.
    I'll keep looking...

  5. #5
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    941
    Vote Rating
    66
    westy is just really nice westy is just really nice westy is just really nice westy is just really nice

      0  

    Default


    Sorted it, eventually.

    Went through process of creating my own cookies, verifying they work, using them to restore my session etc.

    Lots of head scratching and experimentation later and I've come to the conclusion that the IReadOnlySessionState implementation is bugged, you need to use IRequiresSessionState if you require a persistent session id.

    Odd, because sure that was one of the the first things I tried...

    Oh, also spotted that if you have an IIS application within another one you cannot change the stateServer settings in the child.

    Hope this helps someone else, since has been doing my head in

    Cheers,
    Westy

  6. #6
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    941
    Vote Rating
    66
    westy is just really nice westy is just really nice westy is just really nice westy is just really nice

      0  

    Default


    LOL, just broke it again whilst preparing to check-in!

    It seems that if you have no Global.asax for your web service project (even an empty one) then the session cookie is not sent back.

    Grrr!

    PS: Heh, damn caching. You also have to write something to session data in Session_Start, e.g. HttpContext.Current.Session[Guid.NewGuid().ToString()] = 0;

Similar Threads

  1. Adding HTTP Headers to Direct Requests
    By dancablam in forum Ext.Direct
    Replies: 2
    Last Post: 10 Jun 2013, 5:24 AM
  2. Ext.Direct call sending an HTTP OPTIONS cmd
    By ykoehler in forum Ext.Direct
    Replies: 5
    Last Post: 5 Jun 2013, 10:18 PM
  3. Sessions problem
    By Estefan in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 23 Mar 2010, 8:05 AM
  4. sessions: from php to extjs & php
    By sicher in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 9 Apr 2009, 7:16 AM
  5. Handling Sessions
    By acontreras in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 9 Jan 2008, 11:25 AM

Thread Participants: 1

Tags for this Thread