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?
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 can use the SessionStateUtility class to get the session state. Just call:
Api controllers are designed for restful services and should generally be stateless. Not loading the session every time is one of the things that makes them lighter weight.
You need to add this to global.asax
Then you could access the session through:
in the global.asax