ASP.net 会话请求排队 [英] ASP.net session request queuing

查看:18
本文介绍了ASP.net 会话请求排队的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

默认.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

然后你点击 Hang.aspx

Then you hit Hang.aspx

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

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

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.

加载顺序是这样的.

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.

推荐答案

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

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" %>

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

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

设置 EnableSessionState="ReadOnly" 将阻止该页面获得对 SessionState 的排他锁(但页面本身必须等待用户的其他非 ReadOnly 请求在加载之前完成).

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).

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

(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)

这篇关于ASP.net 会话请求排队的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆