请求响应超时在Asp.net

编程入门 行业动态 更新时间:2024-10-25 02:19:56
本文介绍了请求响应超时在Asp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我在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

本文发布于:2023-11-12 01:44:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580159.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!