在Visual Studio中进行调试时,如何查看所有会话键/值对? [英] How to view all Session key/value pairs when debugging in Visual Studio?

查看:129
本文介绍了在Visual Studio中进行调试时,如何查看所有会话键/值对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio(.Net MVC4)中进行调试时,是否可以查看所有键.例如:

When debugging in Visual Studio (.Net MVC4), is it possible to see all Controller.Session key/values at once? I can view all keys by typing Session into QuickWatch and expanding "Results View". E.g:

    Results View
    [0] "IsPlaced"  
    [1] "FromSLC"   
    [2] "PersonalId"    
    [3] "FullName"  

我知道可以检查

Am aware that individual values can be inspected like this but haven't been able to get a list of all keys and values at the same time. Surely this must be possible, either in QuickWatch or the Immediate Window?

推荐答案

我看不到一种简单的方法,最好的办法是编写一个接受HttpSessionState并将其转换为字典的方法,然后从快速监视"窗口调用该方法.更为复杂的解决方案是为HttpSessionState和HttpSessionState编写自己的 DebuggerTypeProxy 将其放入autoexp.cs 文件,这种方法的优点是它可以在不同的应用程序中使用,并且不会迫使您仅使用调试代码来弄脏您的解决方案.

I don't see an easy way to do that, your best bet would be to write a method that takes in an HttpSessionState and converts it to a dictionary, and then calling that method from the QuickWatch window. A somewhat more complex solution would be to write your own DebuggerTypeProxy for HttpSessionState and put it in your autoexp.cs file, the advantage of this approach being that it will work across different applications and won't force you dirty up your solution with code that's only of use for debugging.

这篇关于在Visual Studio中进行调试时,如何查看所有会话键/值对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆