ajax - BeginInvoke method and Session State -


i invoking asynchronous pagemethod call client-side. backend code

[webmethod(enablesession = true)]         public static string beginmethodcall()         { //session accessible here             string g = guid.newguid().tostring();                                 func<object> f = () => methodcall();                              iasyncresult asynccall = f.begininvoke(null, f);              lock (asyncthreadpool)                 asyncthreadpool[g] = asynccall;             return g;         }                      [webmethod(enablesession=true)]         public static object endmethodcall(string guid)         {             iasyncresult callresult;             lock (asyncthreadpool)             {                 callresult = asyncthreadpool[guid];                 asyncthreadpool.remove(guid);             }              func<object> f = (func<object>)callresult.asyncstate;             callresult.asyncwaithandle.waitone();              return f.endinvoke(callresult);         }          [webmethod(enablesession = true)]         public static object methodcall()         {             //session not accessible here         } 

session state accessible beginmethodcall() , endmethodcall() not methodcall().

can tell me why lose session state here?

  1. do threads lose session context because asyn calls not thread safe?
  2. is there way access session here?

in case may find useful

beginxxx create new theard , threads not session safe obvious reasons


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -