title: RedirectToRoute("Default") Not Redirecting, Returning LogOn PartialViewResult's HTML Instead
body: <p>Account Page opens like normal:</p>
  
  <pre><code>    public ActionResult Index()
      {            
          return View();
      }
  </code></pre>
  
  <p>this goes to render the following View template: (because at this point there is no CurrentUser, 'user' is null, so it runs  <code>Html.RenderAction("LogOn", "Account");</code>)</p>
  
  <pre><code>&lt;% var user = (WAPConfigUser) HttpContext.Current.Session["CurrentUser"]; 
     if (user == null || user.IsLoggedIn == false || user.IsPublic) 
     {
         Html.RenderAction("LogOn", "Account");
     } else { %&gt;
  
      &lt;span class="PageNavLink"&gt;
          &lt;% Html.RenderPartial("AccountMenu"); %&gt;        
      &lt;/span&gt;
      &lt;div id="IndexContent" class="IndexContent"&gt;
          &lt;% Html.RenderAction("UserList", "Account"); %&gt;    
      &lt;/div&gt;
  
  &lt;% } %&gt;
  </code></pre>
  
  <p>so I type in the username &amp; password, and the following code runs (and the user is added to the Session for retreival later) and I get redirected to the page I want: </p>
  
  <p>(specifically <code>return Redirect(redirect);</code>)</p>
  
  <pre><code>    [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult LogOn(WAPConfigUser user)
      {
          if (!ValidateLogOn(user.UserName, user.Password))
          {
              return PartialView();
          }
          else
          {
              string redirect = "";
              if (Request.QueryString["ReturnUrl"] != null)
              {
                  redirect = Request.QueryString["ReturnUrl"].ToString();
                  return Redirect(redirect);
              }
              else
              {
                  return RedirectToRoute("Default");
              }
          }
      }
  </code></pre>
  
  <p>I then log out and I'm redirected to the logon screen:</p>
  
  <pre><code>public RedirectToRouteResult LogOut()
  {
      Session.Remove("CurrentUser");
      return RedirectToAction("Index", "Account");
  }
  </code></pre>
  
  <p>When I type my username &amp; password again, the first breakpoint that gets hit is: (which attempts to load the entire page, it seems)</p>
  
  <pre><code>    public ActionResult Index()
      {            
          return View();
      }
  </code></pre>
  
  <p>the next breakpoint that gets hit is the line <code>return RedirectToRoute("Default");</code>:</p>
  
  <pre><code>    [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult LogOn(WAPConfigUser user)
      {
          if (!ValidateLogOn(user.UserName, user.Password))
          {
              return PartialView();
          }
          else
          {
              string redirect = "";
              if (Request.QueryString["ReturnUrl"] != null)
              {
                  redirect = Request.QueryString["ReturnUrl"].ToString();
                  return Redirect(redirect);
              }
              else
              {
                  return RedirectToRoute("Default");
              }
          }
      }
  </code></pre>
  
  <p>but if I step through the code my Default route never gets executed. When I step to the next line, it goes to the following line <code>Html.RenderAction("LogOn", "Account");</code> again in my AccountController's Index View and that (just the user control) gets returned to the browser:</p>
  
  <pre><code>&lt;% var user = (WAPConfigUser) HttpContext.Current.Session["CurrentUser"]; 
     if (user == null || user.IsLoggedIn == false || user.IsPublic) 
     {
         Html.RenderAction("LogOn", "Account");
     } else { %&gt;
  
      &lt;span class="PageNavLink"&gt;
          &lt;% Html.RenderPartial("AccountMenu"); %&gt;        
      &lt;/span&gt;
      &lt;div id="IndexContent" class="IndexContent"&gt;
          &lt;% Html.RenderAction("UserList", "Account"); %&gt;    
      &lt;/div&gt;
  
  &lt;% } %&gt;
  </code></pre>
  
  <p>There's a few things I don't understand here. </p>
  
  <ol>
  <li>Why is <code>RedirectToRoute("Default")</code> not redirecting me to the default route?</li>
  <li>Why is the user null after I added it to the Session when I logged in the second time? (i.e., the line <code>var user = (WAPConfigUser) HttpContext.Current.Session["CurrentUser"];</code> should return the logged-in user that I just added to the session previous to this. Instead, that line doesn't get hit by the breakpoint so it seems to have another NOT-logged-in user. It's executing a line that it shouldn't be, on a page that it shoudln't be!</li>
  </ol>
  
  <p>I know I'll probably get shot for adding the user to the Session, but does anyone have any idea what's going on? If more info is needed, ask &amp; I'll update the question.</p>
  
  <p>Thanks</p>
  
  <p>Dave</p>