I am trying to access the Session in Controllers which are part of a webform project. All the session variables are set on ASPX pages
Session["SESSION_KEY_UI_CULTURE"] = ddlLanguage.SelectedValue;
Now on API request from client i need to read Session Variables and perform a task but Session is always null.
[RoutePrefix("api/accounts")]
public class AccountsController : ApiController
{
[Route("config")]
[HttpGet]
public IHttpActionResult GetCompanyConfig()
{
if(HttpContext.Current.Session != null)
{
//Session is always NULL
}
return Ok();
}
}
I have tried removing and adding SessionStateModule in WebConfig file
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>