ASP.Net masterpage Response.Redirect before child call
<p>I have a masterpage and inside that masterpage I have to check if a session is null or not. If the session is null, then there has to be a redirect to a login page.</p>

<p>That is no problem, but the problem is that the masterpage also have controls using the session and the child also uses the session so I get a nullreferenceexception.</p>

<p>I now have this:</p>

<pre><code>protected void Page_init(object sender, EventArgs e)
{
   var session = (ServiceSession)Session["serviceSession"];

   if (session == null)
   {
         Response.Redirect("login.aspx", false);
   }
}
</code></pre>

<p>But the problem is that the controls on the masterpage are also called instead of redirecting immediatly.</p>

<p>So the main question:</p>

<p>How can I redirect immediatly, without loading further things. Because the page_init gets called as first method the redirect should solve my nullreferenceexception, but than I don't need to load all components etc.</p>

<p>Thanks in advance!</p>
