为什么我的ASP.NET网站演技单线程? [英] Why is my ASP.NET site acting single threaded?

查看:239
本文介绍了为什么我的ASP.NET网站演技单线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET网站在IIS中运行,我已经注意到,如果好像一个页面缓慢运行缓慢,所以我成立了一个测试,看看它是否正在运行,如果它是一个单独的线程(即如果一个页面请求正在运行,所有的人必须等待)。我创建了一个非常简单的页面(无母版页,只有默认的A​​SPX code,除了我添加了一个文字倾倒调试code到)与code读取当前时间,睡眠10秒,然后退出,就像这样:

I have an ASP.NET site running in IIS that I've noticed seems to run slow if one page is slow, so I set up a test to see if it was running as if it was a single thread (i.e. if one page request is running, all others must wait). I created a very simple page (no master page, only has the default aspx code except I added a Literal to dump debug code into) with code to read the current time, sleep 10 seconds, and then exit, like so:

protected void Page_Load(object sender, EventArgs e)
{
    DateTime now = DateTime.Now;
    System.Threading.Thread.Sleep(10000);         
    Literal1.Text = now.ToShortDateString() + " " + now.ToShortTimeString() + " " + now.Second + ":" + now.Millisecond;
}

然后我同时打开两个不同的标签页。每个选项卡上的时间戳几乎完全相隔10秒,这在我看来,意味着第二个页面请求被阻止并等待运行前第一个完成。

I then open the page in two different tabs at the same time. The timestamp on each tab is almost exactly 10 seconds apart, which seems to me to mean that the second page request is blocked and waits until the first one completes before running.

我试着在web.config中注释掉所有HTTP模块,并禁止所有code在Global.asax中,但我还是看到了这个问题。

I tried commenting out all http modules in web.config and disabling all code in Global.asax, but I still see this issue.

推荐答案

这听起来像一个会话状态的问题。

This sounds like a session state issue.

访问ASP.NET会话状态是每个会话,这意味着如果两个不同的用户进行并发请求,获得每个单独会话同时授予独占。但是,如果两个并发请求为同一会议上提出的(通过使用相同的SessionID值),第一个请求获取会话信息的独占访问。第二个请求的第一个请求完成后才能执行。 [...]

Access to ASP.NET session state is exclusive per session, which means that if two different users make concurrent requests, access to each separate session is granted concurrently. However, if two concurrent requests are made for the same session (by using the same SessionID value), the first request gets exclusive access to the session information. The second request executes only after the first request is finished. [...]

来源: ASP.Net会话国家概述

尝试禁用在web.config中会话状态(或者将其标记为只读),以确认这确实是问题,或者使用两个不同的浏览器(它可以获取不同的会话)。

Try disabling session state in web.config (or mark it as readonly) to confirm that this is indeed the issue, or use two different browsers (which gets different sessions).

这篇关于为什么我的ASP.NET网站演技单线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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