Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Russell Munro 6 posts 26 karma points
    May 08, 2014 @ 10:15
    Russell Munro
    0

    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!

  • Jamie Pollock 174 posts 853 karma points c-trib
    May 08, 2014 @ 10:50
    Jamie Pollock
    0

    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

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    May 08, 2014 @ 12:11
    Jeroen Breuer
    1

    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 

  • Russell Munro 6 posts 26 karma points
    May 29, 2014 @ 10:28
    Russell Munro
    0

    oh ok. well thanks for the response (and sorry for the sorry reply)

Please Sign in or register to post replies

Write your reply to:

Draft