Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
3.40/5 (2 votes)
See more:
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.
Posted
Updated 5-Sep-18 1:05am
v2

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
 
Share this answer
 
Comments
Sunil Kumar Pandab 21-Sep-12 11:09am    
I have already tested this one. not working...
Sandip.Nascar 21-Sep-12 13:19pm    
Can you check increasing the executiontimeout value? This works fr me.
Sunil Kumar Pandab 24-Sep-12 9:11am    
executionTimeout="3600" means it will work for 1 hour but after using this code time out happens in 1 minute or 1 and half mins. So no need to increase that value. I have also checked by increaseingthat value. Still not working...
Sandip.Nascar 24-Sep-12 9:14am    
That means, some exception occurs in between. Try to log the exception and see what happens.
Sunil Kumar Pandab 24-Sep-12 9:39am    
no exception happens, I have also checked...
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.
 
Share this answer
 
Comments
Sunil Kumar Pandab 24-Sep-12 9:16am    
Can you please give me some small sample code for getting your solution properly.
Christiaan Rakowski 24-Sep-12 9:37am    
Add a new Simple HTTPHandler to your project and fill it with code something like this.

using System.Web;
using System.Threading;

public class WorkHandler : IHttpHandler
{
public bool IsReusable
{
get {return true;}
}

public void ProcessRequest(HttpContext context)
{
Thread thread = new Thread(new ThreadStart(WorkThreadFunction));
thread.Start();
context.Response.Write("Thread started");
}

public void WorkThreadFunction()
{
try
{
// Call methods to do background work
}
catch (Exception ex)
{
// log errors
}
}
}
Sunil Kumar Pandab 24-Sep-12 9:44am    
Then how can i call it from my code behind.
Christiaan Rakowski 24-Sep-12 10:02am    
An HTTPHandler is kind of like a stripped down ASPX page. To call this code you need to make an AJAX call to the handler. So if the handler is called WorkerHandler.ashx, you can use the button's onclientclick for this: onclientclick="$.get(' WorkerHandler.ashx' ); return false;"
Sunil Kumar Pandab 24-Sep-12 10:13am    
I have the complex code. My link button is in between an gridview. Gridview again inside an update panel. After doing bulk task it open a popup panel with an another gridview. If i will go through your suggestion then i have to fully changed my code. Are you 100 percent sure that your suggestion will work for me(My page will wait for finishing server work). Have you tried this before in your code. I have tried handler before for loading images in other projects but here scenario is different.
I have solved it myself...

I have just added AsyncPostBackTimeout="3600" in ScriptManager's property and it is working. The code is given below :-

XML
<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="3600">
    </asp:ScriptManager>



It is working fine in my local machine and also in the server machine where my project hosted.

But After hosting it is not working in user's machine who is using my project through hitting my project URL. Is there any IIS setting i have to do for update panel AsyncPostBack Timeout.

I need Immediate help...
Thanks in advance...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900