Monday, March 21, 2016

Access HTTP Session in ASP.NET Web API

By default ASP.NET Web API controller methods cannot access HTTP session. To make session available use the following code.

Global.asax

1
2
3
4
        protected void Application_PostAuthorizeRequest()
        {
            System.Web.HttpContext.Current.SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior.Required);
        }

No comments:

Post a Comment