Monday, July 16, 2012

ASP.NET MVC–Model Error Visualizer

July 16, 2012 Posted by Jason Irwin , , No comments

To scratch my own itch (so to speak), I created a Visual Studio visualizer for ASP.NET MVC, allowing ModelState errors to be seen at a glance. This is particularly useful when debugging async requests when and modelstate are not displayed on screen. The visualizer works on the ModelStateDictionary type, iterating through the dictionary and presenting any errors and the associated property name in a datagridview (see the below screenshots).

I built this with VS2012 RC, but the code is simple enough that it should be trivial to modify it to work with older version of VS. The code and download are up on github. Just drop it into your Visual Studio 2012 Visualizers folder and you should be good to go. Feel free to use and abuse (and fork) it in whatever way your heart desires.



Visualizer in debug mode





For example, when I turn client-side validation off on the default Razor web application and forget to enter a password, I get the following: