We figured out how to enable session state with webapi Sample here
Now we have WebApi 2 attribute routing, so we no longer have route object to inject custom handler.
Is there any way of enabling session state with attribute routing?
You need to add this to global.asax
protected void Application_PostAuthorizeRequest()
{
System.Web.HttpContext.Current.SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior.Required);
}
Then you could access the session through:
HttpContext.Current.Session
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With