Feb 23, 2012 09:54 AM|jamesjbigler|LINK
We are trying to convert an asmx web service to a Web API. We have a custom session provider configured in our web.config file. With our asmx webservice we add the attribute
[WebMethod(EnableSession = true)]
to our web method and this triggers a call to GetItem in our SessionStateStoreProvider class. If you don't add EnableSession=true then the GetItem method is never called and HttpContext.Current.Session is null.
Is there an equivalent attribute for a Web API? I have tried setting [SessionState(SessionStateBehavior.Required)] on my Api Controller and also made my APIController implement IRequiresSessionState but no matter what I do I cannot get asp to trigger the
GetItem method of our SessionStateStoreProvider class. As a result HttpContext.Current.Session is always null inside of our Web Api method.
Can anyone help me? I am stumped.