58

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?

Druid
  • 6,423
  • 4
  • 41
  • 56
ctrlShiftBryan
  • 27,092
  • 26
  • 73
  • 78

7 Answers7

94

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"
rdans
  • 2,179
  • 22
  • 32
CodeRedick
  • 7,346
  • 7
  • 46
  • 72
  • 3
    where should this be added? server side / client side, any further explanation would be much appreciated. – owen gerig Aug 10 '13 at 06:40
  • Doubling the seconds allowed before timeout by setting the AsynchPostBackTimeout="180" worked great for my solution. – landsteven Dec 23 '13 at 12:48
  • @owengerig this property should be added in your ScriptManager – ihebiheb Jan 27 '14 at 16:16
  • @owengerig : this is a property of ScriptManager, so it can be added on client side but if you want to be dynamic, you can also access it from server side using id of ScriptManager eg.sc1.AsyncPostBackTimeout = "300" – Mitesh Vora Sep 16 '14 at 10:36
48

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;
}
narayan
  • 553
  • 5
  • 6
  • 1
    Hi @narayan will this work for `RadScriptManager` also? – Nagib Mahfuz Jan 12 '18 at 14:14
  • @NagibMahfuz, unfortunately do not have the means to try out RadScriptManager so I cannot answer definitely. If you ever try it yourself, let us know how it worked out. – narayan Jan 31 '18 at 16:57
11

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> 
ctrlShiftBryan
  • 27,092
  • 26
  • 73
  • 78
9

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.

Musakkhir Sayyed
  • 7,012
  • 13
  • 42
  • 65
rajalingam
  • 91
  • 1
  • 2
2

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.

Bravax
  • 10,453
  • 7
  • 40
  • 68
1

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.

NotMe
  • 87,343
  • 27
  • 171
  • 245
1

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!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Pradeep atkari
  • 549
  • 1
  • 8
  • 14