This page cannot be displayed error when calling a long stored procedure

575 Views Asked by At

I am calling a stored procedure using ASP.Net page. The stored procedure takes a long time so I have set database command timeout property to 0 which means infinite. I have also set executionTimeout in web.config to 7200 which means 2 hours.

When stored procedure is called from that page, after a long time it throws error:

This page can't be displayed

enter image description here

I have written try catch block and set break point but it doesn't come inside catch.

How do I fix this issue?

EDIT

Here's the code:

try
{
//database is Sybase
ConnectionOpenedHere();
AseCommand command = new AseCommand();
command.Connection = con;
command.CommandType = CommandType.StoredProcedure;
command.CommandTimeout = 0;
//some more code here
command.CommandText = storedProcedure;
command.ExecuteNonQuery();    //The code doesn't go beyond this line and shows error after a long time
}
catch (Exception ex)
{
    Response.Write(ex.Message);
}

EDIT

Finally able to catch the exception. Here's the error:

Error: Connection to Sybase server has been lost. All active transactions have been rolled back

Stack Trace: at Sybase.Data.AseClient.AseCommand.CheckResult(Int32 res) at Sybase.Data.AseClient.AseCommand.Execute() at Sybase.Data.AseClient.AseCommand.ExecuteNonQuery() at MyWebsite.Database.MyStoredProcedure(Int32 subtype, string idno)

There is no Inner Exception.

1

There are 1 best solutions below

0
On

Try below solution in your web.config file. Hope this will works. It will hold execution extended till your Store Procedure runs..

But your Store Procedure must be perfect.

<appSettings>
 <add key="aspnet:MaxHttpCollectionKeys" value="9999" /> 
</appSettings>
<system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1048576"/>
      </requestFiltering>
    </security>
  </system.webServer>
  <System.Web>
     <httpRuntime maxRequestLength="102400" executionTimeout="3600" requestValidationMode="2.0"/>
  </System.Web>
 <sessionState timeout="10000"/>  

And Add Machine Key also