如何增加 ASP.NET Ajax PageMethod 的超时?
我有一个 ASP.NET 页面,其中有几个在代码旁边用 [WebMethod]
装饰的静态方法,这些静态方法又使用 PageMethods.MyMethodName(myParameter, myOnCompleteHandler, myOnErrorHander) 从 javascript 调用;
。
其中一种方法会被多次调用,由于调用量较大,运行时间可能会很长。目前,该方法运行正常,但需要 5 分钟以上才能完成的调用会超时。我想把这个时间延长到 10 分钟。
我尝试过:
ScriptManager.AsyncPostBackTimeout = 600;
Server.ScriptTimeout = 600;
this.Page.AsyncTimeout = new TimeSpan(0,10,0);< /code>
Sys.Net.WebRequestManager.set_defaultTimeout(600000);
在 JavaScript 中
I have an ASP.NET page with several static methods decorated with [WebMethod]
in the code-beside, which in turn are called from javascript using PageMethods.MyMethodName(myParameter, myOnCompleteHandler, myOnErrorHander);
.
One of the methods is called multiple times, and the runtime can be long due to the volume of calls. Currently, the method is functioning correctly, but calls that take >5 minutes to complete are timing out. I would like to increase that span to 10 minutes.
I have tried:
ScriptManager.AsyncPostBackTimeout = 600;
Server.ScriptTimeout = 600;
this.Page.AsyncTimeout = new TimeSpan(0,10,0);
Sys.Net.WebRequestManager.set_defaultTimeout(600000);
in javascript
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将以下行添加到 system.web 部分的 web.config 中。
回复晚了,但这也许会对下一个人有所帮助。
Add the following line to your web.config in the system.web section.
Late response, but maybe this will help the next person.
正确的答案是此处,因为 AJAX 超时是由脚本管理器控制的,而不是 http 执行超时。
您需要获取 scriptmanager 控件(在代码或标记中)并根据需要将 AsyncPostBackTimeout 属性设置为合适的值。
The correct answer is here as the AJAX timeout is control by the script manager not the http execution timeout.
You need to get hold of the scriptmanager control (either in code or markup) and set the AsyncPostBackTimeout property to a suitable value as you desire.