I'm writing a simple blogging platform with ASP.NET MVC. My question is regarding forms contained in partial views and handling the response, validation errors or success, from the controller.
I have a blog post item view which has an associated controller that returns a post for a given URL. Embedded in this view is a partial view containing a form for submitting comments on the post. The partial view form submits to a separate controller that handles adding comments. Inside the add comment action I perform validation and add errors to the ModelState object.
The problem is that I have to return a RedirectResult on the partial view action so that the user is returned to the originating post item, which means that I lose the ModelState object or any success messages I want to return.
I've seen people mention the use of TempData to pass validation or success information back to the original view, but to me this sounds a bit hackish. Is this really the solution? If so can anyone recommend a good example of its usage? If not, is this a sign of bigger problems in my chosen architecture?