asp.net - 如果使用 ASP.Net session 状态,AJAX 调用是否在服务器上以串行方式处理?

标签 asp.net ajax asp.net-mvc session

在阅读70-486引用书时,我发现了一段对我来说似乎不正确的段落。

"The design of session state, as implemented in ASP.NET, implies that only one request from a particular user’s session occurs at a time. This means that if you have a page that includes multiple, independent AJAX callbacks happening at once, these calls will be processed in serial fashion on the server. If your application is sessionless, it can also handle AJAX callbacks in parallel rather than requiring that the work be performed in serial, which enables you to perform multiple, simultaneous AJAX calls from the client."

我可以谈谈你对此的看法吗?我知道 AJAX 调用始终是并行的,无论 session 或状态如何。

最佳答案

这句话完全正确。 ASP.NET Session 不是线程安全的,并且不允许来自同一 session 的并行请求。它会阻止它们并按顺序执行。

AJAX 请求是并行的,只不过它们来自同一 session (将相同的 ASPSession cookie 发送到服务器),因此服务器将简单地阻止它们并按顺序执行。所以基本上你从客户端发送并行请求,但服务器不会并行处理它们。

这就是为什么当我启动 ASP.NET 应用程序时我要做的第一件事就是确保在 web.config 中完全禁用 session :

<sessionState mode="Off" />

关于asp.net - 如果使用 ASP.Net session 状态,AJAX 调用是否在服务器上以串行方式处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20560631/

相关文章:

javascript - Linux Ajax (mootools Request.JSON) header 错误

asp.net - 为什么我的空模型能够验证?

ajax - CakePHP:在 ajax 之后呈现 View

c# - 如何上传100MB的文件?

c# - 在 ASP.NET MVC 5 中使用区域的路由属性

c# - 监控 .NET ASP.NET 应用程序

javascript - 关闭浏览器窗口而不等待ajax响应的最佳实践

asp.net-mvc - "test"服务器中的 ASP.NET MVC 运行时安装要求

c# - .NET c# - 自定义显示属性

asp.net - Jquery AJAX 与 WebMethod 删除前面的零