ASP.NET Development Server concurrent processing doesn't work

痞子三分冷 提交于 2019-11-28 04:25:17

问题


I'm trying to find out why ASP.NET Development Server is not processing the requests concurrently.

So I've created a simple aspx page with the following code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

System.Threading.Thread.Sleep(10000)

End Sub

If I open the page two times, the response takes 20 seconds. That means, the server executes requests one by one (not concurrently).

Following advice provided in this topic, I've added EnableSessionState="false" to the page, but that doesn't seem to help.

Any ideas how to make the requests process concurrently?


回答1:


The asp.net dev server (cassini) cannot handle multiple threads. So it effectively processes requests one at a time. Turning session off really won't impact this.

It's really just for limited single user testing of a web app.

I'd recommend you dump cassini and install IIS Express or just go to the full IIS implementation.

A little reading: ASP.NET Dev Server (Cassini), IIS Express and multiple threads




回答2:


IIS on XP doesn't allow that many concurrent connections (I think it's 10). If you're developing in that environment, that may be why you're experiencing that (besides those 2 requests, you have requests for referenced files taking place, plus you may be issuing more requests than you think you are for that particular page).

I'm not sure if VS built-in server has similar limitations.




回答3:


If you're using ASP.NET MVC without disabling SessionState (which by default you would be) your requests will be automatially serialized - so if you're checking for race conditions with a random Thread.Sleep() value then Request B will never complete before Request A even if the time slept for is less.

ASP.NET MVC and Ajax, concurrent requests?



来源:https://stackoverflow.com/questions/9036150/asp-net-development-server-concurrent-processing-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!