views:

191

answers:

3

In my application this code:

CreditsSubjectsNamesTeacherCount n = new CreditsSubjectsNamesTeacherCount();
Session["UserID"] = n.GenerateTeacherCountCrossRegions(txtStartYear.Text.CheckOnEmptyYear(), ((UserInformation)Session["UserInformation"]).UserName);
Response.Redirect("page.aspx");


doesnt redirect if the method GenerateTeacherCountCrossRegions was executing for a long time(~ >10 min). What can cause this problem?
PS: added:
<httpRuntime executionTimeout="18000".. > but it didnt help.
Thank you.

+3  A: 

The request has timed out. Response.Redirect sends an HTTP response asking the browser to request a different page - if the request has timed out at the browser, it won't accept this response.

David M
thank you for the answer..I had the same thought, but changing executionTimeout in web.config didnt help either..May be i've missed something?
nihi_l_ist
The timeout is on the browser side, so changing a setting on the server won't help...
RickNZ
I think this is a client-side timeout, not something you can control in a server-side setting...
David M
think you're right..and how can i fix that? :(
nihi_l_ist
Get the time of the method down to under 10 minutes, find the browser setting and advise all your users to set it appropriately (!!!), or investigate some sort of asynchronous approach, where (for example) the page is redirected to while the method runs, and then the server is polled at intervals to see if it has completed.
David M
A: 

The request will time out, so the browser will display an error rather than the expected page. Note that this will likely not happen while debugging, only on deployment.

For long running operations of this kind consider a different interface.

I've created a system where the analyzed data is sent by email to the user when it's been calculated: internally I've spawned off a BackgroundWorker thread to do the calculation that then uses a MailMessage to send the report as a PDF attachment.

Jeremy McGee
+2  A: 

The browser has stopped waiting for the page, so there is no longer a connection. The server just sends the redirect into void, where noone is listening.

Start the work in a separate thread, so that the response doesn't have to wait for it to complete. Redirect to a page that reloads occationally to check the status of the work, and redirect to the final page when the work is complete.

To communicate with the background thread you need an object that both threads has a reference to. You can store a reference to the object in a session variable so that the page checking the status has access to it.

Guffa
added the background thread+removed update panel on page and it works now :) (tho didn't manage the progress display functionality, but still..)
nihi_l_ist