这可能是一个很愚蠢的问题,但答案很简单,但我似乎找不到任何相关信息。
我正在为客户端内部创建一个 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 存储......他们不应该在那里吗?)我很确定我不久前读过一个关于这个的教程,但我现在似乎找不到它。
我需要添加一些额外的代码吗?
最佳答案
您无法在客户端查看 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/