I have a design question. I am implementing a purchase flow in my Web that has 4 steps:
A -> B -> C <-> D -> E
PurchaseModel
object and POST
it to B.
I need the PurchaseModel
travelling from A to E, so my question is:
How can I pass the PurchaseModel
between controllers/views? What is the recommended solution in this case?
NOTE: A, B, C and D are controllers that have the attribute [AllowAnonymous]
.
Would be correct to store the PurchaseModel
in a session variable in STEP B, and then use it in the other controllers?
I think an action should only take parameters that are relevant to it. In the case of registration or login I see these as separate concerns, so it would be wrong to pass a PurchaseModel to them. If you were passing data between different steps that is relevant to all steps I would do it via passing a common view model, or models that inherit from one another, but as this is not how it is in your case I would store in session. This will not be affected by logging in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With