views:

1259

answers:

5

I'm encountering a situation where it takes a long time for ASP.NET to generate reply with the web page (more than 2 hours). It due to the codebehind running for a while (very long, slow loop).

Browser (both IE & Firefox) stops waiting for the reply (after about an hour) and gives generic cannot display webpage error (similar to what you would see if you'd try to navige to non-existing server).

At the same time asp.net app keeps going (I can see it in debugger) and eventually completes.

Why does this happen? Are there any settings in web.config to influence this? I'm hoping there's a timeout setting that I'm missing that's causing this.

Maybe a settings in IE or Firefox? But I think they wait while the server is keeping connection alive.

I'm experiencing this even when I launch app in debug mode (with compilation debug="true") on my local machine from VS (so it's not running on IIS, but on ASP.NET Dev Server).

I know it's bad that it takes so long to generate the page, but it doesn't matter at this stage. Speeding it up would take a lot of extra work and the delay doesn't really matter. This is used internally.

I realize I can redesign around this issue running logic to a background process and getting notified when it's done through AJAX, or pull it to a desktop app or service or whatever. Something along those lines will be done eventually, but that's not what I'm asking about right now.

A: 

For something that takes this long, I would figure out a way to kick it off via AJAX and then periodically check on it's status. The background process should update some status variable on a regular basis and store it's data in the cache or session when complete. When it completes and the browser detects this (via AJAX), have the browser do a real postback (or get by changing location.href), pick up the saved data, and generate the page.

tvanfosson
+1  A: 

The entire paradigm of the Web is of request/response. Not request, wait two hours, response!

If the work takes so long to do, then have the page request trigger the work, and then not wait for it. Put the long-running code into a Windows service, and have the service listen to an MSMQ queue (or use WCF with an MSMQ endpoint). Have the page send requests for work to this queue. The service will read a request, maybe start up a new thread to process it, then write a response to another queue, file, or whatever.

The same page, or a different, "progress" page can poll the response queue or file for responses, and update the user, assuming the user still cares after two hours.

John Saunders
+2  A: 

Sounds like you're using IE and it is timing out while waiting for a response from the server.

You can find a technet article to adjust this limit:

http://support.microsoft.com/kb/181050

CAUSE

By design, Internet Explorer imposes a time-out limit for the server to return data. The time-out limit is five minutes for versions 4.0 and 4.01 and is 60 minutes for versions 5.x, 6, and 7. As a result, Internet Explorer does not wait endlessly for the server to come back with data when the server has a problem. Back to the top

RESOLUTION

In general, if a page does not return within a few minutes, many users perceive that a problem has occurred and stop the process. Therefore, design your server processes to return data within 5 minutes so that users do not have to wait for an extensive period of time.

ninj
this looks like it. I'll test it. thanks!Is there a similar setting in Firefox?
Ornus
kind of.FF2 has a config setting called network.http.connect.timeoutFF2 and FF3 have a config setting called network.http.keep-alive.timeout, although I'm not entirely sure this will do what you want.you can find all FF config entries here:http://kb.mozillazine.org/About:config_entries
ninj
A: 

I have a process that can take a few minutes so I spin off a separate thread and send the result via ftp. If an error occures in the process I send myself an error message including the stack trace. You may want to consider sending the results via email or some other place then the browser and use a thread as well.

A: 

Hi, the above link for IE5 and IE6 says browser timeout is 60 seconds. Is this true? Is the value 60 minutes?

stranger001
you really should create a new question, instead of asking question in the answers section.
Ornus