title: How to redirect to another MVC View with Model after Angular $http.post
body: <p>I am trying to redict to another MVC View from a an Angular 1.6 <code>$http.post</code>. Basically I want to go to another View (Checkout) to display the options user has selected from Details page. The trouble I am having is that if I go directly to Checkout I get a NullReferenceException, so I tried this:</p>
  
  <p>Angular:</p>
  
  <pre><code>model.submitDetails = function () {
  
          // Commented out code results in NullReferenceExeption - not binding the data
  
          //var data = {
          //    car: model.car, colour: model.colour, features: model.features, cover: model.cover
          //}
  
          //window.location = 'http://localhost:50592/Cars/Checkout?vm=' + data;
  
  
          $http.post('http://localhost:50592/Cars/DetailsSubmit',
                  { car: model.car, colour: model.colour, features: model.features, cover: model.cover })
              .then(function (response) {
                  window.location.href = response;
              }, function (err) {
                  model.error = err.data;
                  console.log(err.data);
          });
      };
  </code></pre>
  
  <p>The above <code>$http.post</code> results in a 404 error. If I don't include the <code>.then</code>, e.g. comment it out, I can see in the Network tab in F12 dev tools that the <code>$http.post</code> is returning the html directly rather than rendering the Checkout View page.</p>
  
  <p>My MVC Controller Code:</p>
  
  <pre><code>[HttpPost]
  public ActionResult DetailsSubmit(CheckoutViewModel vm)
  {
      TempData["car"] = vm.Car;
  
      vm.StartDate = DateTime.Now;
      vm.EndDate = DateTime.Now.AddDays(7);
  
      return RedirectToAction("Checkout", vm);
  }
  
  public ActionResult Checkout(CheckoutViewModel vm)
  {
      vm.Car = (Car)TempData["car"];
  
      return View(vm);
  }
  </code></pre>
  
  <p>To how can I redirect successfully to the Checkout page from the <code>submitDetails()</code> Angular function? Any help getting this working would be greatly appreciated.</p>