title: Handling AJAX requests if a session has expired
body: <p>In my app (ASP.NET MVC 3 RAZOR), when a session expires and the user tries to access something, it redirects them to the login page to re-login.</p>
  
  <p>This is fine, but when calling from ajax requests (e.g. if the user has left their screen for a while with no activity), it will load the login form in the ajax request... Which is not what I want to happen.</p>
  
  <p>What is the best way of dealing with this? Ideally I'd like to show a modal if the session has expired so the user can't access other areas. So even if they leave the screen some jQuery will have checked the session and then applied a modal saying 'Session Expired'</p>
  
  <p>How would I do this?</p>
  
  <p>e.g.</p>
  
  <pre><code>if(SESSION HAS EXPIRED) { showModal(); }
  </code></pre>