ASP.NET MVC: ModelState vs. ModelStateDictionary

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2009-08-18T05:06:29Z Indexed on 2010/03/28 23:33 UTC
Read the original article Hit count: 491

Hello, I have a service which has a method that's called when a certain controller method is triggered.

My service returns a custom result object PlacementResult in which I want to communicate errors that may have happened (validation) back to the controller method.

Should PlacementResult have a ModelState or a ModelStateDictionary to communicate errors back to the controller (and finally view)? How would I string this together?

Finally, how do I get the ModelState/ModelStateDictionary (whichever you tell me I should choose) back into the view (highlighting the appropriate text box, show the error message etc.)?

Thank you !

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET