Click here to Skip to main content
14,740,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900