teenup
teenup

Reputation: 7667

How can I dump entire ViewModel to View in asp.net MVC?

Inspite of seeing the model by setting breakpoint, I want to dump each and every object inside the ViewModel to its corresponding View in Action method, so that I can see its properties in the browser.

Is there any direct method for doing this in asp.net MVC just like we have in PHP Zend Framework ?

Upvotes: 1

Views: 745

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039298

You could JSON serialize the model in the view:

<pre>
    <%= new JavaScriptSerializer().Serialize(Model) %>
</pre>

or use XML format if you prefer.

Upvotes: 3

Related Questions