jQuery的阿贾克斯 - 运行针对ASP.NET MVC的多个请求 [英] jQuery Ajax - Running multiple requests against ASP.NET MVC

查看:162
本文介绍了jQuery的阿贾克斯 - 运行针对ASP.NET MVC的多个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标签式的网页,一旦在页面加载每个选项卡打完一个Ajax请求的内容(使用jQuery)。后端是ASP.NET MVC运行在Visual Studio所以才用正常的ASP.NET开发服务器服务的要求。我遇到了以下问题:

I have a 'tabbed' style web page where once the page loads each tab fires off an Ajax request for their content (using jQuery). The backend is ASP.NET MVC running in Visual Studio so just with the normal 'ASP.NET Development Server' servicing the requests. I am experiencing the following issues:

1)的请求是由Web服务器一次处理。第二个请求是没有处理,直到第一个完成。这在某些单线程模式下的ASP.NET开发服务器运行?我可以把它的多线程(和我应该让多线程或将这项开辟一个痛苦的世界?)

1) The requests are processed by the web server one at a time. The second request is not dealt with until the first completes. Is this the 'ASP.NET Development Server' running in some single threaded mode? Can I make it multithreaded (and should I make it multithreaded or would this open up a world of pain?)

2)的长时间运行的请求杀死后续请求。鉴于该请求被服务的一个在即使我发射了Ajax请求全部一次,一时间,为什么做的一些要求不,即使在Web服务器到达?这发生一次很长的请求已被提供服务。例如:

2) Long running requests kill off subsequent requests. Given that the requests are being serviced one at a time even though I am firing off the ajax request all at once, why do some of the requests fail to even arrive at the web server? This happens once a long request has been serviced. For example:

  • 在第一次请求(小小的请求) - 响应好
  • 第二请求(大 要求) - 反应需要一分钟或 所以但并获得服务。
  • 第三请求 (小的要求) - 要求从来没有 到达服务器和jQuery也 未报告错误。
  • 1st Request (small request) - response okay
  • 2nd Request (large request) - response takes a minute or so but does get serviced.
  • 3rd Request (small request) - request never arrives at the server and jQuery does not report an error.

我已经试过增加了ajax超时,但没有成功。

I have tried increasing the ajax timeout but with no success.

更新: 我发现,被搞乱的URL到最后请求,以便它看起来像这样无关的请求长度和Ajax超时我在code中的错误(脸红!)。一路上,虽然我已经找到了有用的ajaxManager插件,它是伟大的排队请求,如果这是你所需要的(http://www.protofunc.com/scripts/jquery/ajaxManager/)。此外,由于有关使用ASP.NET开发服务器来测试对正确的观点。这的确是从IIS中完全不同。

Update: I have found a bug in my code that was messing up the URL to the final request so it looks like this has nothing to do with the request length and ajax timing out (blushes!). Along the way though I have found the useful ajaxManager plugin which is great for queueing up request if that is what you need (http://www.protofunc.com/scripts/jquery/ajaxManager/). Also, thanks for the valid point about using the ASP.NET Dev Server to test against. It is indeed quite different from IIS.

推荐答案

至于1点记住,如果你使用会话状态,则该请求将不会同时执行 - ASP.NET将锁定会话状态和将只处理使用它一次每个请求。 (在 http://msdn.microsoft.com见一节并发请求和会话状态 / EN-US /库/ ms178581 获得更多信息)尝试禁用会话状态(如果你不使用,当然啦!),看看有没有什么帮助。

With regards to point 1 bear in mind that if you're using session state then the requests will not perform concurrently - ASP.NET will lock the session state and will only process each request that uses it one at a time. (See the section 'Concurrent Requests and Session State' in http://msdn.microsoft.com/en-us/library/ms178581 for more info) Try disabling session state (if you're not using it of course!) and see if that helps.

这篇关于jQuery的阿贾克斯 - 运行针对ASP.NET MVC的多个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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