title: MVC Equivalent of Page_Load
body: <p>I have a session variable that is set in my MVC application.  Whenever that session expires and the user tries to refresh the page that they're on, the page will throw an error because the session is not set anymore.</p>
  
  <p>Is there anywhere I can check to see if the session is set before loading a view?  Perhaps putting something inside the Global.asax file?</p>
  
  <p><strong>I could do something like this at the beginning of EVERY ActionResult</strong>.</p>
  
  <pre><code>public ActionResult ViewRecord()
  {
      if (MyClass.SessionName == null)
      {
          return View("Home");
      }
      else
      {
          //do something with the session variable
      }
  }
  </code></pre>
  
  <p>Is there any alternative to doing this?
  What would the best practice be in this case?</p>