I just got done adding a few REST-like Base methods to my web site and came across a bit of an issue with how the incoming requests are handled. I'm calling the base methods via a jQuery ajax GET request. When I do that, the HttpContext.Current.Session state object is null. Is this behavior a limitation of how Base works? That is, is Session simply not available via Base methods? If it is available, what do I need to do to get access to a non-null session?
This is a case also in webservices however you can turn on state in webservice using attribute WebMethod(EnableSession:=True) see http://msdn.microsoft.com/en-us/library/aa480509.aspx you may be able to do something similar in base?
I believe it's because Base requests are handeled in the BeginRequest event and at this stage the Session object will still be null as it hasn't been initialized by the ASP.NET runtime yet. We should probably move the handling code to an event that occurs after PostAcquireRequestState. In the meantime you could write a custom handler that overrides the default one and update web.config with your own.
MissingSession State for Base Methods
I just got done adding a few REST-like Base methods to my web site and came across a bit of an issue with how the incoming requests are handled. I'm calling the base methods via a jQuery ajax GET request. When I do that, the HttpContext.Current.Session state object is null. Is this behavior a limitation of how Base works? That is, is Session simply not available via Base methods? If it is available, what do I need to do to get access to a non-null session?
Acoustic,
This is a case also in webservices however you can turn on state in webservice using attribute WebMethod(EnableSession:=True) see http://msdn.microsoft.com/en-us/library/aa480509.aspx you may be able to do something similar in base?
Regards
Ismail
I believe it's because Base requests are handeled in the BeginRequest event and at this stage the Session object will still be null as it hasn't been initialized by the ASP.NET runtime yet. We should probably move the handling code to an event that occurs after PostAcquireRequestState. In the meantime you could write a custom handler that overrides the default one and update web.config with your own.
FYI. fixed in v4.1
is working on a reply...