I know REST should be stateless.
My Web Api is at the same project of my MVC Website. How can I share the session between them?
I'm trying to use the goodies of Web Api 2 and work with Ajax rather than build a RESTful API.
stolen from this question
in global.asax add the following:
public override void Init()
{
this.PostAuthenticateRequest += MvcApplication_PostAuthenticateRequest;
base.Init();
}
void MvcApplication_PostAuthenticateRequest(object sender, EventArgs e)
{
System.Web.HttpContext.Current.SetSessionStateBehavior(
SessionStateBehavior.Required);
}
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