如何在 Visual Studio 2008 调试器中查看会话变量?

发布于 2024-08-27 08:20:05 字数 261 浏览 3 评论 0原文

通常使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

演出会有结束 2024-09-03 08:20:05

在调试期间检查会话非常简单。只需在代码中放置一个断点,然后突出显示您的 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 select QuickWatch....

This will setup up a watch on your Session for the value you had defined. You can also inspect other Session elements by adjusting the Expression field in the QuickWatch window and clicking the Reevaluate button.

往事随风而去 2024-09-03 08:20:05

在 VS 中,您可以将 'Session["first_name"]' 放入立即窗口中,并在代码运行时执行。这将返回它所保存的值。

如果找不到它,请转到:查看>其他窗口>命令窗口,或按Ctrl+W、A,

它将如下所示:
Screenshot:

我知道回复有点晚了,但对于其他感兴趣的人来说,我希望这会有所帮助!

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:
Screenshot:

I know its a bit of a late reply but for anyone else who is interested, I hope this helps!

樱娆 2024-09-03 08:20:05

不是HttpContext.Current.Session("...")吗,我好久没用ASP.NET了。

Isn't it HttpContext.Current.Session("..."), I ask as I haven't used ASP.NET for a long time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文