I have a web service that has an MVC controller and a WepAPI 2 controller.
The job of the MVC controller is to render and return HTML for a partial view. A different MVC application makes that call and then embeds the resulting HTML into its own page.
The partial view contains some controls that make calls to the WebAPI controller to temporarily store data. For this purpose I enabled session in the WebAPI controller using this code in Global.asax.cs
:
protected void Application_PostAuthorizeRequest() {
HttpContext.Current.SetSessionStateBehavior(
System.Web.SessionState.SessionStateBehavior.Required);
}
When the calling application makes the call to the MVC controller, it passes a model to it. This model contains some initial data that the controls on the partial view need to display. This is the same kind of data the controls will create/update/delete using the WebAPI controller. I want to put the data from the model into the session so that the controls in the partial view would be able to read/update/delete this data.
My question is this: Is there any way to give the MVC controller access to the WepAPI session? Or is there any way to make the WebAPI controller use the same session as the MVC controller uses?