In a small web app I'm making for internal use, I want the user to be able to select one of the data files to open. I have a strongly typed view which takes the list of files as the model.
My initial version had an Index action which got the list of data files and returned the view, then a Create action for creating a new file, and an Upload action for uploading an existing file. However, in both cases it would be a bad user experience to have a whole new page just for a single text box and button, so I added two forms to the Index view, one pointing to Create, the other to Upload, both using the Post verb.
This works perfectly fine, plus still retains nice URL naming - even though Create/Upload don't have UIs. The problem is that at the end of both of these actions, I do a return RedirectToAction("Index"); Which in turns gets the data to be displayed and shows the view - fine. But I get no validation. It seems that in order to get the ValidationSummary and ValidationMessage helpers to work, I need the Post action to be called the same as the Get action (Index, in this case). I changed everything so that I just have a Get/Post Index action, and an if statement in the Post action to see if the button was Create or Upload. But this seems like a far clunkier solution than the one I originally came up with.
The other option, of course, is to create views for Create/Upload, each with the single text box - but I'd rather hve the clunky code than the clunky UI.
Is there anything I'm missing, or is this just the way the MVC validation framework is designed.