Click here to Skip to main content
14,422,431 members
Rate this:
Please Sign up or sign in to vote.
See more:
please help me how to enable session in asp.net api?, have any attributes for that?
Posted
Updated 25-Nov-19 0:29am
Rate this:
Please Sign up or sign in to vote.

Solution 3

The small issue about enable the session on the API call is you need to add to all the calls on teh API, on WebForms you can add only on teh call you need use the session. Fro me the most easy way is enable on the Global.asax.

protected void Application_PostAuthenticateRequest(object sender, EventArgs e)
        {
            //implement session on api calls
                HttpContext.Current.SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior.Required);
        }


With this action you already can get a session from the API.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100