开发者

How to debug ASP.NET MVC Controller after it passes control to the View?

About once every 20 page loads, I get a glitch in my View. I'd like to know what values the variables in my Control开发者_C百科ler contained right before it called the View. However, once the View is called I lose all local variables from the Controller. Is there any hope?


Use ModelVisualizer Helper in mvc.contrib It renders all values into the view.


The watch window's "Make Object ID" feature will let you watch variables which are out of scope.


You could add extra output on your view page to show you variable value / states for debugging information until you resolve the issue.


Apologies if I'm missing something obvious but can't you set a conditional breakpoint in the Controller just prior, or on, the View call? The condition can be based on execution count. Once stopped you can step into the View.

I realize you lost the Controller local variables as they are out of scope as soon as you step into the View but can't be that hard to write them down, append to a large string (ie Flash message) and output in view, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜