ASP.NET MVC 和 Ajax,并发请求? [英] ASP.NET MVC and Ajax, concurrent requests?

查看:36
本文介绍了ASP.NET MVC 和 Ajax,并发请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是 AJAX 新手!
目前在我的 ASP.NET MVC Web 应用程序中,我的 AJAX 请求似乎正在批处理或排队,我不确定.
在上一个请求完成之前,似乎没有任何请求正在完成.
如何让请求独立返回?
我不一定希望有人给我答案,但也许有一些指向好的教程或资源的链接可以提供帮助.谢谢

AJAX newbie here!
At the moment in my ASP.NET MVC web app my AJAX requests appear to be getting batched or queued, im not sure.
No requests seem to be getting completed until the previous request has finished.
How do I go about getting the requests to return independantly?
I dont necessarily want someone to give me the answer but maybe some links to good tutorials or resources which could help. Thanks

推荐答案

我正在扩展 Lachlan Roche 的答案,这是正确的.

I'm expanding on Lachlan Roche's answer, which is correct.

ASP.NET 框架将处理会话范围的单线程"请求(一种全局资源),以防止一个请求干扰另一个请求.在 WebForms 中,我认为您可以使用 Page 指令来指定各个页面不使用 Session,因此不需要像这样同步处理.

The ASP.NET framework will "single-thread" requests that deal with Session scope (a global resource), to prevent one request from interfering with another. In WebForms I think you can use the Page directive to specify that individual pages don't use Session and therefore don't need to treated synchronously like this.

问题是在ASP.NET MVC中所有请求都使用Session,因为它是用来实现TempData的.正如 Lachlan Roche 指出的那样,您可以完全禁用会话状态,也可以逐案处理.

The problem is that in ASP.NET MVC all requests use Session, because it's used to implement TempData. You can disable session state entirely, as Lachlan Roche pointed out, or you can deal with this on a case-by-case basis.

一个可能的解决方案可能是启动您自己的后台线程来处理任何长时间运行的代码,以便初始请求尽快完成".

A possible solution might be to kick off your own background threads to process any long-running code, so that the initial request "completes" as quickly as possible.

这篇关于ASP.NET MVC 和 Ajax,并发请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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