title: Passing a View Model within a URL.Action
body: <p>I'm trying to pass a view model to my controller.</p>
  
  <pre><code> @if (User.IsInRole("Customer"))
              {
  
                  &lt;input type="button" class="btn btn-danger" value="Rent Car" onclick="location.href='@Url.Action("PassingCar", "Bookings", new { id = item.VehicleID, Model = Model.Booking })'" /&gt;
  
              }
  </code></pre>
  
  <p>I'm using a dynamic model so I can use both Vehicle and Booking in this view.</p>
  
  <p>When the code gets to my controller the ID has been passed over but the data in the ViewModel is gone. </p>
  
  <pre><code> public ActionResult PassingCar( int id, CreateBookingViewModel createdModel)
          {
              ///Checks that Vehicle exists in DB and v property is not null
              if (v == null)
              {
                  return HttpNotFound();
              }
              else
              {
  
  
                  /// sets the Vehicle attribute of the BookingViewModel to vehicle passed over
                  createdModel.Vehicle = v;
  
              }
              return RedirectToAction("Create", "Bookings");
          }
  
  </code></pre>
  
  <p>If anybody has an idea what i'm doing wrong it would be greatly appreciated.</p>