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 172 posts 846 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 4861 posts 12138 karma points MVP 3x 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)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies