Reputation: 88
Is there a way to view what HTML has already been produced by an MVC Razor View when stepping through it with a debugger?
For example, in a view such as the following:
...
@Html.Raw(someString)
@Html.Partial("_SomeCommonComponent")
@Html.Raw(someOtherString) <---------- Execution broken at breakpoint here
...
Is it possible to see the combined output of just the first call to 'Raw' and the Partial view?
The reason I ask is that I have several complex calls together, (some which produce no output at all) and one of them is inserting incorrect characters, and I'd like to be able to find which call is the culprit by stepping over the code until the incorrect character has been output.
Upvotes: 4
Views: 1657
Reputation: 331
In Visual Studio you could put a break point on a code line in the view, then add a watch on both the Html.Raw(somestring) and Html.Partial("_SomeCommonComponent") method calls. You should then be able to see the HTML values in the watch window.
Also try and watch the ViewContext.Writer property in the view.
Upvotes: 1