c# - 在浏览器中查看 session 变量

标签 c# asp.net session

这可能是一个很愚蠢的问题,但答案很简单,但我似乎找不到任何相关信息。

我正在为客户端内部创建一个 web 应用程序,并且我正在使用 session 变量,这些变量在他们登录时开始。

例如:

Session["ConsultantFirstname"] = adAuth.getFirstName();
Session["ConsultantLastName"] = adAuth.getLastName();

//Then I also have a reader on page load which creates these...

while (reader.Read())
{
    Session["Department"] = reader[1].ToString();
    Session["Channelid"] = reader[2].ToString();
    Session["EmailAddress"] = reader[3].ToString();
    Session["PrimaryTerritory"] = reader[4].ToString();
}

我的问题是……我如何在浏览器中看到创建了哪些 session 变量? (如果我选择“检查元素”>“资源”> session 存储......他们不应该在那里吗?)我很确定我不久前读过一个关于这个的教程,但我现在似乎找不到它。

enter image description here

我需要添加一些额外的代码吗?

最佳答案

您无法在客户端查看 session 状态变量。 Session 状态存储在服务器端,客户端浏览器只知道 SessionID 存储在 cookie 或 URL 中。

MSDN说:

Sessions are identified by a unique identifier that can be read by using the SessionID property. When session state is enabled for an ASP.NET application, each request for a page in the application is examined for a SessionID value sent from the browser. If no SessionID value is supplied, ASP.NET starts a new session and the SessionID value for that session is sent to the browser with the response.

By default, SessionID values are stored in a cookie. However, you can also configure the application to store SessionID values in the URL for a "cookieless" session.



Google Chrome provides some extension 您可以通过它来编辑 cookie。

关于c# - 在浏览器中查看 session 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23102629/

相关文章:

c# - 将 GeoJSON 响应转换为 FeatureCollection

asp.net - 直接在包含ASP.NET中内容控件的内容页面中仅允许内容控件

ASP.NET:为什么编译后需要很长时间才能加载页面?

java - Spring 安全 : session expiration without redirect to expired-url?

c# - 在 ASP.NET 中处理从多个 session 到数据库的多个插入

c# - 反序列化 xml 返回空

c# - 如何知道当前时间是否在两个时间跨度之间?

c# - 在 MVC3 中随时间动态改变主题

c# - 池回收上的 ASP.NET Websocket 行为

session - Zend Framework - session ID 重新生成,无法保持登录状态