如何在 Visual Studio 2008 调试器中查看会话变量?
通常使用 Visual Studio 的调试器是轻而易举的。扫描 Locals 可以快速显示变量的值等。但是,我不知道如何找出会话状态变量中包含的值?有人可以帮我吗? 假设我在以下位置放置了一个断点:
Session["first_name"] = "Rob Roy";
How do I view the value contains in Session["first_name"]
from locals?
Usually using Visual Studio's debugger is a breeze. Scanning through Locals quickly shows the values of variables, etc. However, I'm at a loss how to find out the values contained in session state variables? Can anyone give me a hand?
Let's say I put a breakpoint right after:
Session["first_name"] = "Rob Roy";
How do I view the value contained in Session["first_name"]
from locals?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在调试期间检查会话非常简单。只需在代码中放置一个断点,然后突出显示您的
Session
代码(例如突出显示:Session["first_name"]
),然后右键单击并选择QuickWatch.. .
。这将在您的
Session
上为您定义的值设置一个监视。您还可以通过调整 QuickWatch 窗口中的Expression
字段并单击Reevaluate
按钮来检查其他Session
元素。It's pretty simple to inspect the session during debug. Just put a breakpoint in your code and just highlight your
Session
code (eg. highlight:Session["first_name"]
) then right click and selectQuickWatch...
.This will setup up a watch on your
Session
for the value you had defined. You can also inspect otherSession
elements by adjusting theExpression
field in the QuickWatch window and clicking theReevaluate
button.在 VS 中,您可以将 'Session["first_name"]' 放入立即窗口中,并在代码运行时执行。这将返回它所保存的值。
如果找不到它,请转到:查看>其他窗口>命令窗口,或按Ctrl+W、A,
它将如下所示:
我知道回复有点晚了,但对于其他感兴趣的人来说,我希望这会有所帮助!
In VS you can just put 'Session["first_name"]' in the Immediate Window and execute while the code is running. That will return the value that it holds.
If you can't find it go to: View > Other Windows > Command Window, or press Ctrl+W, A
It will look like this:
I know its a bit of a late reply but for anyone else who is interested, I hope this helps!
不是
HttpContext.Current.Session("...")
吗,我好久没用ASP.NET了。Isn't it
HttpContext.Current.Session("...")
, I ask as I haven't used ASP.NET for a long time.