Hi,
I try to implement a new Checkout step "Dimensions", between "PaymentMethod" and "Confirm" steps.
I implemented views and models, and modified the CheckoutController.
In the CheckoutControler, I add 2 Methods "Dimensions" and "SelectDimentions" (based on "PaymentMethod" and "SelectPaymentMethod").
public ActionResult Dimensions() { CheckoutDimensionsModel model = new CheckoutDimensionsModel(); return View(model); } [HttpPost, ActionName("Dimensions")] [FormValueRequired("nextstep")] public ActionResult SelectDimensions(CheckoutDimensionsModel model) { if (ModelState.IsValid) { return RedirectToAction("Confirm"); } //If we got this far, something failed, redisplay form return View(model); }
The new step is present when I try to order a Product, the "Next" button works fine and calls well the SelectDimensions method.
But in the SelectDimensions method, the model (received as parameter) seems to be empty (the constructor is called just before).
Testing steps for Dimensions :
- Display web page in browser
- Hits VisualStudio breakpoint on "Dimensions()" in CheckoutController, which calls CheckoutDimensionsModel constructor
- Enter some value and click "Next" on web page
- Hits VisualStudio breakpoint on "SelectDimensions(CheckoutDimensionsModel model)" in CheckoutController, which calls CheckoutDimensionsModel constructor
- The model in "SelectDimensions(CheckoutDimensionsModel model)" contains nothing
When analysing the way it works with the similar step PaymentMethod, it seems the constructor of the Model is also called, but right after, the model recover values entered in the view.
The only difference between this is that SmartModelBinder.BindModel is called from out of hell !
Testing steps for ShippingAddress :
- Display web page in browser
- Hits VisualStudio breakpoint on "ShippingAddress()" in CheckoutController, which calls CheckoutShippingAddressModel constructor
- Enter some value and click "Next" on web page
- Hits VisualStudio breakpoint on "NewShippingAddress(CheckoutShippingAddressModel model)" in CheckoutController, which calls CheckoutShippingAddressModel constructor
- Hits VisualStudio breakpoint on "BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)" in SmartModelBinder, which seems to properly initialize entered values
- The model in "NewShippingAddress(CheckoutShippingAddressModel model)" contains entered values
Not easy to discribe this, and really not easy to understand why it doesn't works.
Some help will be gracefull.