how to handle the error message: Session state is not available in this context
<p>I am trying to create an error message page to display exception when exception occurs, and there is a return button on error message page to return the previous page where the exception caused.</p>

<p>here is the code used to redirect the error page. </p>

<pre><code>protected void btnAssign_Click(object sender, EventArgs e)
{
    try
    {
        SqlDataSource3.Insert();
    }
    catch (Exception ex)
    {
        Session["Exception"] = ex;
        Response.Redirect("~/ErrorMessage.aspx", false);
    } 
}
</code></pre>

<p>here is the code for my global.asax file</p>

<pre><code>void Application_Error(object sender, EventArgs e) 
{ 
    // Code that runs when an unhandled error occurs
    Exception ex = Server.GetLastError().InnerException;
    Session["Exception"] = ex;
    Response.Redirect("~/ErrorMessage.aspx");
}
</code></pre>

<p>here is the code for errorMessage page.</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Exception ex = (Exception)Session["Exception"];
            Session.Remove("Exception");
            Literal1.Text = "&lt;p style='color:blue'&gt;&lt;b&gt;An unrecoverable error has occurred:&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style='color:red'&gt;" + ex.Message + "&lt;/p&gt;";
        }  
    }
    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IncidentAssignment.aspx");
    }
</code></pre>

<p>When I click the assign button, it opens the errorMessage page and display the exception, but when I click return button, the program crashed and pointed to global.asax file and says Session state is not available in this context, as shown in blew.
<img src="http://i.stack.imgur.com/J0j9b.jpg" alt="enter image description here"></p>

<p>I don't get it why is the session["exception"] Null. it will be much appreciated if anyone answered my question. Thanks.</p>
