Response.Redirect的不2分钟后子程序工作 [英] Response.Redirect doesn't work after 2 minutes subroutine

查看:86
本文介绍了Response.Redirect的不2分钟后子程序工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我绑定一个asp按钮,通过这些步骤,生成一个XLS文件子程序:

I've bound an asp button to a subroutine that generates an xls file through these steps:


  1. 执行一些SQL查询(成功)

  2. 构建与由此产生的数据集(成功,2MB)Excel文件

  3. 重定向当前页面到DownloadPage.aspx?=文件名的标准操作来构建和下载文件

不过,在这一点上,即使Excel文件在源文件夹中找到它不会启动任何下载。奇怪的是,有时它的工作原理,随机。
没有异常被扔但线程中止dued来重定向。

But at this point it doesn't start any download even if the excel file is available in the source folder. The strange thing is that sometimes it works, randomly. No exception is throwed but the Thread Abort dued to redirection.

所以,我没有别的想法......你知道吗?

So, I haven't other ideas...Do you?

感谢

P.S。我试图设置一些参数,IIS 6分钟以上。

p.s. I've tried to set some IIS parameters to 6 minutes or over.

推荐答案

2分钟,一个的非常的很长一段时间的Web请求。足够长的时间,大多数客户会放弃,或者通过浏览器超时或用户导航离开的手段。为什么要花这么长时间来实现请求?有没有什么可以改善显著瓶颈?运行某些SQL查询和建立一个Excel文件,不应该花这么长时间。它也被认为是从服务器的角度来看一个非常糟糕的主意,有一个请求撑起IO了这么久。如果有很多用户,他们可以磨服务器正常使用该网站的停了下来。

2 minutes is a very long time for a web request. Long enough that most clients will give up, either by means of the browser timing out or the user navigating away. Why does it take so long to fulfill the request? Is there a significant bottleneck you can improve? Running some SQL queries and building an Excel file shouldn't take that long. It's also considered a very bad idea from the perspective of the server to have a request hold up IO for so long. If there are many users they can grind the server to a halt by normal use of the site.

如果它真的应该这么长的时间,你可能要考虑一个异步的方式。而不是让用户等待一个重定向,立即提供某种形式的反馈。发送用户指示其请求已被接收到并正在处理的页面。然后,他们可以继续使用该网站。当他们的数据准备好,该网站可以提供某种通知链接,让他们知道。

If it really is supposed to take so long, you may want to consider an asynchronous approach. Instead of having the user wait for a redirect, immediately provide some kind of feedback. Send the user to a page indicating that their request has been received and is being processed. They can then continue to use the site. When their data is ready, the site can provide some kind of notification link to let them know.

在后端,该网站可以揭开序幕另一个线程来完成工作。或者说,这往往是一个Web应用程序更好,你可以排队在一个数据库中的请求,并有一个Windows服务或计划的控制台应用程序,民意调查数据库的新请求,处理它们,并将输出保存在Web应用程序可以寻找它。然后在Web应用程序的通知系统将只检查输出每个请求(或者通过AJAX或凉爽的东西类似的查询吧)通知该数据已准备好用户。

On the back end, the site can either kick off another thread to do the work. Or, and this is often better for a web application, you can queue the request in a database and have a Windows Service or scheduled console application poll that database for new requests, process them, and save the output where the web application can look for it. Then the notification system in the web application would just check for output with each request (or maybe poll it via AJAX or something cool like that) to notify the user that the data is ready.

这篇关于Response.Redirect的不2分钟后子程序工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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