title: Why jquery ajax calls fails after session timeout in asp.net mvc?
body: <p>when there is a value in my session variable my ajax calls work properly... But when a session is timedout it doesn't seem to work returning empty json result.... </p>
  
  <pre><code>public JsonResult GetClients(int currentPage, int pageSize)
          {
              if (Session["userId"]!=null)
              {
                  var clients = clirep.FindAllClients(Convert.ToInt32(Session["userId"])).AsQueryable();
                  var count = clients.Count();
                  var results = new PagedList&lt;ClientBO&gt;(clients, currentPage - 1, pageSize);
                  var genericResult = new { Count = count, Results = results ,isRedirect=false};
                  return Json(genericResult);
              }
              else
              {
                  var genericResult = new {redirectUrl = Url.Action("Create", "Registration"), isRedirect = true };
                  return Json(genericResult);
              }
  
          }
  </code></pre>
  
  <p>However else part does'nt seem to work....</p>
  
  <pre><code>   success: function(data) {
         alert(data.Results);
          if (data.isRedirect) {
              window.location.href = data.redirectUrl;
          }
     }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>My global.asax has this,</p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
          {
              routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
              routes.MapRoute(
                  "Clients",                                             
                  "Clients/{action}/{id}",                          
                  new { controller = "Clients", action = "Index", id = "" }  
              );
  
              routes.MapRoute(
                 "Registrations",                                              
                 "{controller}/{action}/{id}",                          
                 new { controller = "Registration", action = "Create", id = "" } 
             );
          }
  </code></pre>