请求响应超时在Asp.net [英] Request Response Time out in Asp.net

查看:93
本文介绍了请求响应超时在Asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在gridview中点击一个按钮时,我在服务器中有一些批量工作,它再次位于更新面板(异步回发)中。我的大量工作是进行API调用,保存生成的文件,读取该文件,在gridview中显示。我的问题不是批量工作。但批量工作需要很长时间才能完成,而我的请求页面并没有等待完成。因为超时,我没有得到任何结果。



如何解决?如何等待我的页面完成服务器中的所有工作?



我需要立即帮助,因为我浪费了很多时间并尝试了很多东西。

I have some bulk work in server when I just hit a button in gridview which is again inside an Update Panel(Asynchronous post back). My bulk work is to make an API call, save the resulted file, reading that file, showing that in a gridview. My problem is not bulk work. But bulk work taking much times to finish and my request page is not waiting for finish. So I am not getting any result because of time out.

How to solve it? How to wait my page for finishing all work in server?

I need immediate help because I have wasted much time and also tried many things.

推荐答案

您可以在web.config中使用executiontimeout



You can use the executiontimeout in web.config

<system.web>
    <httpruntime>
      executionTimeout="3600"
      maxUrlLength="10000" 
      maxQueryStringLength="80000" />



</httpruntime></system.web>





这将解决您的问题。



欢呼



This will solve your problem.

cheers


我自己解决了这个问题......



我刚刚在ScriptManager的属性中添加了AsyncPostBackTimeout =3600,它正在运行。代码如下: -



I have solved it myself...

I have just added AsyncPostBackTimeout="3600" in ScriptManager's property and it is working. The code is given below :-

<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="3600">
    </asp:ScriptManager>







它是在我的本地机器以及我的项目托管的服务器机器上正常工作。



但托管之后,用户的机器无法通过点击我的项目URL来使用我的项目。是否有任何IIS设置我必须为更新面板AsyncPostBack超时。



我需要立即帮助...

提前致谢..


在web.config中使用executionTimeout参数可以帮助解决直接问题,但如果你需要等待多于一个只需要杀死ASP.NET部分并让正常C#接管,这样用户就可以与应用程序的其他部分进行交互了。



要做到这一点,只需在事件处理程序中启动一个Thread,然后退出处理程序,让Thread继续运行。线程将在新线程中进行批量处理,您的Web应用程序将立即响应,因此不会超时。



供用户查看你必须在页面上实现某种更新机制的更新数据。

为此,你可以让线程在代码完成后设置一个标志。

以特定间隔使用AJAX调用来轮询将传递标志状态的HttpHandler。

如果标志设置为done,则更新面板/ GridView的内容,或者只是重新加载整个页面(如果可能的话)。



我希望这对你有帮助。
Using the executionTimeout parameter in the web.config can help solve the direct problem, but if you need to wait more than a minute it might be worth it to just kill the ASP.NET part and let "normal" C# take over, this way the user will be able to interact with other parts of your application.

To do this simply start a Thread in your event handler, and then exit out of the handler, leaving the Thread to run. The Thread will do the bulk processing in a new thread, and your web application will give an instant response, so it won't timeout.

For the user to see the updated data you will have to implement some kind of update mechanism on the page.
To do this, you could let the Thread set a flag in your code when it is done.
Use AJAX calls at a certain interval to poll an HttpHandler that will pass the status of the flag.
If the flag is set to done, update the content of the panel/GridView, or just reload the entire page (if possible).

I hope this helped you.


这篇关于请求响应超时在Asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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