如何查看所有会话键/值对在调试时? [英] How to view all Session key/value pairs while debugging?

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

问题描述

当在Visual Studio(.NET MVC4)调试,是有可能看到所有的 Controller.Session 键/值一次?我可以通过键入会话进入快速监视和扩大结果查看查看所有。例如:

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"  

所知,个别值可以被检查<一href="http://stackoverflow.com/questions/2549424/how-to-view-session-variables-in-visual-studio-2008-debugger#answer-2549510">like这但一直没能得到的所有键和值列表在同一时间。当然,这必须是可能的,无论是在快速监视或即时窗口?

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并将其转换为一个字典,然后调用从快速监视窗口的方法。一个稍微更复杂的解决办法是写自己的 DebuggerTypeProxy 的HttpSessionState和把它放在你的autoexp.cs 文件,优点这种方法是,它会在不同的应用工作,不会强迫你弄脏了code的解决方案,它只是用于调试。

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.

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

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