Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: IIS7 C# ASP.NET
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 21-Sep-12 3:06am
Edited 21-Sep-12 4:52am
Nueman8.1K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Sunil Kumar Pandab at 21-Sep-12 11:09am
   
I have already tested this one. not working...
Sandip.Nascar at 21-Sep-12 13:19pm
   
Can you check increasing the executiontimeout value? This works fr me.
Sunil Kumar Pandab at 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 at 24-Sep-12 9:14am
   
That means, some exception occurs in between. Try to log the exception and see what happens.
Sunil Kumar Pandab at 24-Sep-12 9:39am
   
no exception happens, I have also checked...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I have solved it myself...
 
I have just added AsyncPostBackTimeout="3600" in ScriptManager's property and it is working. The code is given below :-
 
<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...
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
Sunil Kumar Pandab at 24-Sep-12 9:16am
   
Can you please give me some small sample code for getting your solution properly.
Christiaan Rakowski at 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 at 24-Sep-12 9:44am
   
Then how can i call it from my code behind.
Christiaan Rakowski at 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 at 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.
Christiaan Rakowski at 24-Sep-12 10:53am
   
I use this way of working quite often for bulk background processing, but never with a real 'busy waiting' scenario, like you have right now. So I can't be a 100% certain it will work for you, and if your code is quite complex then completely rewriting/organizing can be very time consuming. However, this is this the only system I know of that can help in this scenario (other than the request timeout variable in the web.config). I see above that you already tried this, and I find it strange that it will still timeout so quickly. Other than my solution here, another thing might be to just optimize the bulk processing part.

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

  Print Answers RSS
0 Maciej Los 245
1 OriginalGriff 210
2 Manfred R. Bihy 190
3 CHill60 180
4 _Amy 155
0 OriginalGriff 7,445
1 Sergey Alexandrovich Kryukov 6,157
2 Maciej Los 3,774
3 Peter Leow 3,448
4 CHill60 2,702


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100