ASP.NET UpdatePanel 超时

发布于 2024-07-06 08:12:01 字数 232 浏览 7 评论 0 原文

我正在从 UpdatePanel 发出请求,该请求需要超过 90 秒。 我收到此超时错误:

Microsoft JScript 运行时错误: Sys.WebForms.PageRequestManagerTimeoutException:服务器请求 超时。

有谁知道是否有办法增加呼叫超时之前的时间?

I'm making a request from an UpdatePanel that takes more then 90 seconds. I'm getting this timeout error:

Microsoft JScript runtime error:
Sys.WebForms.PageRequestManagerTimeoutException: The server request
timed out.

Does anyone know if there is a way to increase the amount of time before the call times out?

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

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

发布评论

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

评论(7

潜移默化 2024-07-13 08:12:01

ScriptManager 上有一个属性允许您设置超时(以秒为单位)。 默认值为 90 秒。

AsyncPostBackTimeout="300"

There is a property on the ScriptManager which allows you to set the time-out in seconds. The default value is 90 seconds.

AsyncPostBackTimeout="300"
妞丶爷亲个 2024-07-13 08:12:01

就我而言,ScriptManager 对象是在母版页文件中创建的,然后与内容页文件共享。 因此,要更改内容页面中的 ScriptManager.AsyncPostBackTimeout 属性,我必须访问内容页面的 aspx.cs 文件中的对象:

protected void Page_Load(object sender, EventArgs e)
{
     . . . 
     ScriptManager _scriptMan = ScriptManager.GetCurrent(this);
     _scriptMan.AsyncPostBackTimeout = 36000;
}

In my case the ScriptManager object was created in a Master Page file that was then shared with the Content Page files. So to change the ScriptManager.AsyncPostBackTimeout property in the Content Page, I had to access the object in the Content Page's aspx.cs file:

protected void Page_Load(object sender, EventArgs e)
{
     . . . 
     ScriptManager _scriptMan = ScriptManager.GetCurrent(this);
     _scriptMan.AsyncPostBackTimeout = 36000;
}
是伱的 2024-07-13 08:12:01

这成功了(基本上只是忽略所有超时):

<script type="text/javascript"> 
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function (sender, args) { 
            if (args.get_error() && args.get_error().name === 'Sys.WebForms.PageRequestManagerTimeoutException') { 
                            args.set_errorHandled(true); 
            } 
        }); 
    </script> 

This did the trick (basically just ignoring all timeouts):

<script type="text/javascript"> 
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function (sender, args) { 
            if (args.get_error() && args.get_error().name === 'Sys.WebForms.PageRequestManagerTimeoutException') { 
                            args.set_errorHandled(true); 
            } 
        }); 
    </script> 
挥剑断情 2024-07-13 08:12:01

请按照以下步骤操作:

步骤 1:在 web.config 中,设置 httpRuntime maxRequestLength="1024000"executionTimeout="999999"

步骤 2:将以下设置添加到您的网站页面的 ScriptManager: AsyncPostBackTimeout ="360000"

这将解决您的问题。

Please follow the steps below:

Step 1: In web.config, set httpRuntime maxRequestLength="1024000" executionTimeout="999999"

Step 2: Add the following setting to your web page's ScriptManager: AsyncPostBackTimeout ="360000"

This will solve your problem.

棒棒糖 2024-07-13 08:12:01

这可以通过更改 IIS 中的 ASP 脚本超时进行配置。

它位于网站属性、虚拟目录、配置按钮中,然后位于选项选项卡上。

或通过设置 Server.ScriptTimeout 属性来设置它。

This might be configurable by changing the ASP script timeout in IIS.

It's located in the properties of your web site, virtual directory, configuration button, then on the options tab.

or set it by setting the Server.ScriptTimeout property.

苹果你个爱泡泡 2024-07-13 08:12:01

好吧,我想如果您只是希望丢弃该请求,并且可能永远不会完全执行,那么这会起作用...

将 AsyncPostBackTimeOut 属性添加到 ScriptManager 标记,以将默认超时从 90 秒更改为对您的应用程序更合理的值。

此外,考虑更改接收呼叫的 Web 服务以加快速度。 90秒对于互联网时间来说可能是无限的。

Well, I suppose that would work if you just want the request thrown away with the potential that it never completely executed...

Add an AsyncPostBackTimeOut property to the ScriptManager tag to change your default timeout from 90 seconds to something more reasonable for your application.

Further, look into changing the web service receiving the call to move faster. 90 seconds may as well be infinity in internet time.

天赋异禀 2024-07-13 08:12:01

您面临的问题是当您的应用程序在 SQL 数据库查询上遇到超时时。 返回输出需要比默认时间更多的时间。 所以需要增加ConnectionTimeout属性。

您可以通过多种方式完成此操作:

  1. 连接字符串具有 ConnectionTimeout 属性。 该属性决定代码等待打开数据库连接的最大秒数。 您可以在 web.config 的连接字符串部分设置连接超时。

    <连接字符串> 
          <添加名称=“连接字符串”  
               连接字符串=“数据库= UKTST1;服务器= BRESAWN;uid=”system.data.sqlclient=“/>
  2. 您可以将AsyncPostBackTimeout="6000"放入.aspx页面

     
       
      
  3. 您可以在SqlCommand中设置超时,您在其中调用 .cs 文件中的存储过程。

    command.CommandTimeout = 30*1000; 
      

希望你有解决办法!

The problem you are facing is when your application runs into a timeout on a SQL database query. It's taking more time than the default to return the output. So you need to increase the ConnectionTimeout property.

You can do it in several ways:

  1. A connection string has a ConnectionTimeout property. It is a property that determines the maximum number of seconds your code will wait for a connection of the database to be opened. You can set connection timeout in connection string section in web.config.

    <connectionstrings>
        <add name="ConnectionString" 
             connectionstring="Database=UKTST1;Server=BRESAWN;uid="      system.data.sqlclient="/><br mode=" hold=" /><br mode=" html="> <asp:ToolkitScriptManager runat=" server=" AsyncPostBackTimeOut=" 6000="><br mode=">
        </add>
    </connectionstrings>
    
  2. You can put AsyncPostBackTimeout="6000" in .aspx page

    <asp:ToolkitScriptManager runat="server" AsyncPostBackTimeOut="6000">
    </asp:ToolkitScriptManager>
    
  3. You can set timeout in SqlCommand, where you are calling the stored procedure in .cs file.

    command.CommandTimeout = 30*1000;
    

Hope you have a solution!

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