I'm trying to use a session in an MVC application, I believe you're right but you're returning the error:
Object reference not set to an instance of an object
When it tries to pass the value in the session and the value is not null.
I think this is not the proper way to use MVC session, does anyone know what I'm doing wrong?
[HttpPost]
[Route("FiltroSiltDet")]
public HttpResponseMessage FiltroSiltDet(string DT_INCLUSAO)
{
try
{
HttpSessionState Session = HttpContext.Current.Session;
Session["DT_INCLUSAO"] = "test";
Session["DT_INCLUSAO"] = DT_INCLUSAO;
List<AcompanhamentoSiltDetDTO> retorno = new List<AcompanhamentoSiltDetDTO>();
using (AcompanhamentoSiltBLL oBLL = new AcompanhamentoSiltBLL())
{
retorno = oBLL.AcompanhamentoSiltTransacaoDet(DT_INCLUSAO);
}
var resp = Request.CreateResponse<List<AcompanhamentoSiltDetDTO>>(HttpStatusCode.OK, retorno);
return resp;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}