Hi Russell,
I'm afraid I don't have experience with this personally. After a bit of a Google I found the following regarding general .net WebApi, which UmbracoApiController is based upon.
It seems to suggest that accessing the HttpContext Session in what should be a "stateless" Api Controller isn't a desirable route (no pun intended ;)) to follow.
It's not recommended to uses sessions with WebAPI because it's supposed to be stateless. Instead you could create a surface controller and communicate with that. Since it's a normal controller sessions are allowed.
Session with UmbracoApiController?
I have implement an UmbracoApiController as described here http://our.umbraco.org/documentation/Reference/WebApi/ and it works great.
I would now like to access HttpContext.Current.Session in the methods but it always returns null. is it possible to do so? If so how do you do it?
Thanks!
Hi Russell,
I'm afraid I don't have experience with this personally. After a bit of a Google I found the following regarding general .net WebApi, which UmbracoApiController is based upon.
http://stackoverflow.com/questions/11478244/asp-net-web-api-session-or-something
It seems to suggest that accessing the HttpContext Session in what should be a "stateless" Api Controller isn't a desirable route (no pun intended ;)) to follow.
You may find the solution works for you though.
Thanks,
Jamie
Hello,
It's not recommended to uses sessions with WebAPI because it's supposed to be stateless. Instead you could create a surface controller and communicate with that. Since it's a normal controller sessions are allowed.
Jeroen
oh ok. well thanks for the response (and sorry for the sorry reply)
is working on a reply...