Hi all In my MVC application for booking accommodation I have the following:
- Action to display the selected room with input-forms for extra info GET:"Details" This view has multiple forms on it, each posting to a different action.
Examples:
- Action to update the number of guests POST:"UpdateGuests"
- Action to select start date POST:"SelectStartDate"
- Action to add breakfast POST:"AddBreakfast"
- Action to delete room POST:"RemoveProductFromCart"
- Action to proceed to next step POST:"Proceed"
Most of these actions will redirect back to the GET:"Details" view so the user can perform another action if required, in the case of the proceed, this will redirect to the next view OR if there is some reason they cannot proceed it will display the validation message as to why on the "Details" view.
I'm not sure of the best way to deal with validation, here's some options I've thought of.
- use TempData[] to store validation messages and REDIRECT to "Details" view where we add any TempData errors so the ModelState.
- in the POST:"xxxxxx" Action populate the ModelState and RENDER the "Details"
This is not a high volume site so TempData is an option.
Any ideas gratefully welcomed.
Edit: Additional info:
- I'm using DataAnnotations for validation rules in some places.
- adding Ajax as progressive enhancement is planned, but it should work without.