ASP.NET 后台处理阻止状态或 UI 反馈

发布于 2024-08-11 04:04:59 字数 503 浏览 10 评论 0原文

我知道这个问题已经被问过很多次了,但我的问题有点不同。

我有一个页面可以让用户下载和上传 Excel 文件。下载 Excel 期间,生成文件大约需要 2 分钟。我添加了检查点,这些检查点会更新数据库的状态(开始处理、处理标头...等)。我对上传做了同样的事情。

我还有一个 ajax 请求,它以固定的时间间隔检查数据库并向用户打印状态以提供反馈,例如(开始处理、处理标题等)。

问题是,只有在该过程完成后我才能得到反馈。看起来会话在后台进程期间被阻止,并且任何其他请求(ajax)只有在后台进程结束后才会完成。 ajax 在 4 秒的间隔内发出大约 10 个请求。我最终只收到 10 个响应。

我尝试了两个 iframe 和框架,一个运行 ajax,另一个运行进程,但不起作用。我尝试了单独的浏览器(在 IE 中运行的进程,在 FF 中运行的 ajax)并且可以工作(所以我现在我的代码可以工作)。有人可以建议吗?谢谢

​我的环境是IIS 6,ASP.NET 3.5 with MVC 1.0 浏览器是IE6.0

I know this question has been asked many times, but my problem is a little different.

I have page which lets user download and upload excel file. During downloading excel, it takes approx 2 mins to generate the file. I have added checkpoints which updates the database with status like (started processing, working on header ...etc). I have done the same thing for upload.

I also have a ajax request which checks the database in fixed interval and prints status to user to give feedbacks like (started processing, working on header ...etc).

The problem is, i get the feedback only when the process is complete. It looks like the session is blocked during the background process and any other request(ajax) are only completed once the background process is over. ajax makes approx 10 requests within 4 sec intervals.I get the 10 response back only in the end.

I have tried two iframes and also frames, one running the ajax and other running the process, Doesn't work. i tried separate browser(Process running in IE, ajax running in FF) and that works (so i now my code works). Can anybody advise? Thanks

p.s. My environment is IIS 6, ASP.NET 3.5 with MVC 1.0 browser is IE6.0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

音栖息无 2024-08-18 04:04:59

您的浏览器对可以同时工作的连接数有限制。

我相信 IE 有 2 个连接的限制。这意味着即使您正在运行 AJAX 请求,也只能同时运行两个请求。

这很可能就是为什么您直到最后才看到结果的原因,因为它正在处理其他连接,并且在完成之前不会到达状态请求。这也解释了为什么当您从不同的浏览器执行此操作时它会起作用,因为您不会受到相同的连接限制。

这是一篇详细介绍该问题的文章

Your browser has a limitation on the number of connections that can be working concurrently.

I believe IE has a limitation of 2 connections. That means that even if you are running AJAX requests you can only have two requests running concurrently at the same time.

That is most likely why you're not seeing results until the end, because it's processing other connections and doesn't get to the status request until it's already done. That also explains why it works when you do it from different browsers, because you don't suffer from the same connection limitation.

Here's an article that details the issue.

神魇的王 2024-08-18 04:04:59

这正是我想要的
(asynchronous-processing-in-asp-net-mvc-with-ajax-progress-bar)

使用 IAsyncResult 的委托 BeginInvoke 有助于阻止会话

This is exactly what i was looking for
(asynchronous-processing-in-asp-net-mvc-with-ajax-progress-bar)

Using delegate BeginInvoke of IAsyncResult helped with the blocked session

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文