How do I do validation in mvc if I'm not using models?
I'm directly obtaining data from the controller and displaying it.
How do I validate? Most examples seem to use the model to validate.
Although it is considered to be against MVC paradigm, nothing technically prevents you from working with the posted form directly.
class TestController : Controller
{
[AcceptVerbs (HttpVerbs.Post)]
public ActionResult SomeAction (FormCollection form)
{
if (MyCustomValidation (form))
SaveData ();
RedirectToAction ("SomeAction");
}
}
You could use a service layer as described by this article, this allows both separation of concerns whilst maintaining error handling, not relying on the controller to do it all for you.