views:

446

answers:

3

I have a situation with my MVC2 app where I have multiple pages that need to submit different information, but all need to end up at the same page. In my old Web Forms app, I'd have just accomplished this in my btnSave_Click delegate with a Redirect.

There are three different types of products, each of which need to be saved to the cart in a completely different manner from their completely different product pages. I'm not going to get into why or how they're different, just suffice to say, they're totally different. After they're saved to the cart, I need to "redirect" to the Checkout view. But it should be noted, that you can also just browse straight to the Checkout view without having to submit any products to add to the cart.

Here's a diagram of what I'm trying to accomplish, and how I think I need to handle it: alt text

Is this correct? It seems like a common scenario, but I haven't seen any examples of how I should handle this.

Thank you all in advance.

+1  A: 

It would be good if you had a base Model class for each of these XYZIt items and could pass them as a collection of CheckOutItems to the checkout controller directly instead of having these intermediate controllers in there. Not really sure why you need to have these extra controllers.

Nissan Fan
+1  A: 

Yes, this is certainly one way to handle it. If your widgets, whatzits, and whozits views are really that different, than it's probably not worth it to try any sort of inheritance scheme or smart view that is capable of displaying any of them depending on what's passed in as the view model.

If you're asking for how to handle the redirect, you should probably use RedirectToAction("Action", "Checkout") when handling the save actions on your widget, whatzit, and whozit controllers.

Kevin Pang
A: 

You can use RedirectToAction

Dennis Cheung