Response is not available in this context during page unload
<p>When my asp.net aspx page unloads i am trying to check if the current session is expired.  I have this code in the Page_unlaod and i get a <strong>"Response is not available in this context"</strong> error.   What is the problem placing this code in the Page_unlaod?</p>

<pre><code>protected void Page_Unload(object sender, EventArgs e)
    {
        if (Session["LoggedInUser"] == null)
        {
            Response.Redirect(Request.ApplicationPath.TrimEnd('/') + "/Login.aspx?r=" + Request.Url.ToString(), true);
        }
    }
</code></pre>

<p>the page is in a frame with 3 other pages so when the page is doing a postback, there is client side code that will the page 2 in the frameset to 100% visible, then when page is laoded and the document is ready it sets itself 100% visible in the frame.</p>

<p>I have tried placing the code in page_load but when the session has timedout the pageload is never executed again.  I have tried to place the code in the pageload of page 2 in the frameset but that causes some funny behavior and unwanted redirects.</p>
