ASP.net 会话请求排队

发布于 2024-10-06 00:50:03 字数 853 浏览 6 评论 0原文

在我看来,ASP.net 将所有使用相同会话 ID 的请求排队。假设您有 3 页。

Default.aspx

protected void Page_Load(object sender, EventArgs e)
{
    Session["asdf"] = "LOLZ";
}

如果会话不存在,点击此页面显然会创建一个新会话。

X-AspNet-Version: 2.0.50727
Set-Cookie: ASP.NET_SessionId=ibjphuv0aiafqi453tyze345; path=/; HttpOnly

然后您点击 Hang.aspx

protected void Page_Load(object sender, EventArgs e)
{
    Thread.Sleep(10000);
}

在您点击此会话 ID 将传递到的任何其他页面后,无论它是否执行任何操作,我们都将其称为 Test.aspx。

加载顺序就像这样。

Request            Timeline
"GET /"            |*|
"GET /Hang.aspx"       |******************************************|
"GET /Test.aspx"            |**************************************|

我想我的问题是如何禁用此功能。我知道这样做很有用,这样会话状态就可以更加可预测,但是就我而言,长时间运行的报告页面加载正在扼杀用户执行多任务的能力。

It seems to me that ASP.net queues up all requests that use the same Session ID. Let's say you've got 3 pages.

Default.aspx

protected void Page_Load(object sender, EventArgs e)
{
    Session["asdf"] = "LOLZ";
}

Hitting this page would obviously create a new session if one doesn't exist.

X-AspNet-Version: 2.0.50727
Set-Cookie: ASP.NET_SessionId=ibjphuv0aiafqi453tyze345; path=/; HttpOnly

Then you hit Hang.aspx

protected void Page_Load(object sender, EventArgs e)
{
    Thread.Sleep(10000);
}

And immediately after you hit any other page that this session ID would be passed to, doesn't matter if it does anything, let's call it Test.aspx.

The sequence for loading is like so.

Request            Timeline
"GET /"            |*|
"GET /Hang.aspx"       |******************************************|
"GET /Test.aspx"            |**************************************|

I guess my question is how do I disable this feature. I understand it's useful to have so that session state can be more predictable, however in my case a long running reports page load is killing users' ability to multitask.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

泛泛之交 2024-10-13 00:50:03

此行为是设计使然;不允许同时访问会话状态。具有相同 SessionID 的请求将被专门锁定,以防止其状态的潜在损坏。

为了解决这个问题,您可以在页面指令中禁用会话状态。

<%@ Page EnableSessionState="false" %>

在此处阅读“并发请求和会话状态”http://msdn.microsoft.com/ en-us/library/ms178581.aspx 了解更多信息。

设置 EnableSessionState="ReadOnly" 将阻止该页面获得 SessionState 上的独占锁(但页面本身必须等待用户的其他非 ReadOnly 请求完成才能加载)。

(这是我对此问题的回答的复制和粘贴 ASP.net 站点:用户的长时间加载页面会导致用户的所有其他页面加载暂停

This behaviour is by design; no concurrent access to the session state is allowed. Requests with same SessionID will be locked exclusively to prevent potential corruption of its state.

To get around this you can disable session state in your page directive.

<%@ Page EnableSessionState="false" %>

Read "Concurrent Requests and Session State" here http://msdn.microsoft.com/en-us/library/ms178581.aspx for more.

Setting EnableSessionState="ReadOnly" will prevent that page from gaining an exclusive lock on the SessionState (but the page itself would have to wait for other non-ReadOnly requests by the user to finish before loading).

(This is a copy and paste of my answer to this question ASP.net site: Long-loading page for user puts all other page loads for user on Hold)

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