1

Why Session is null when redirection from one controller to another? And when I refresh the page again I find that the session object is not null and have data!

First controller:

HttpContext.Session["SiteCheckpoint"] = siteCheckpoint;
//redirect to second page controller
Response.Redirect(siteCheckpoint.FirstPageUrl + "?rf =" + referenceId);

Second controller:

if (HttpContext.Session[Resources.SessionParameter.SiteCheckpoint] != null)
{
    GetCheckpointData();
}
else 
{                
    //Raise error page
}

I tried this solution but it didn't work:

<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
Matt Sach
  • 1,162
  • 16
  • 37
hazem
  • 495
  • 1
  • 5
  • 20

1 Answers1

0

i solved my issue since i wasn't define any model in my view i can't pass any data to the second controller

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<BCV4.Web.Redirection.Models.HomeModel>" %>
hazem
  • 495
  • 1
  • 5
  • 20