14

I'll have an ASP.net page that creates some Excel Sheets and sends them to the user. The problem is, sometimes I get Http timeouts, presumably because the Request runs longer than executionTimeout (110 seconds per default).

I just wonder what my options are to prevent this, without wanting to generally increase the executionTimeout in web.config?

In PHP, set_time_limit exists which can be used in a function to extend its life, but I did not see anything like that in C#/ASP.net?

How do you handle long-running functions in ASP.net?

2 Answers 2

16

If you want to increase the execution timeout for this one request you can set

HttpContext.Current.Server.ScriptTimeout

But you still may have the problem of the client timing out which you can't reliably solve directly from the server. To get around that you could implement a "processing" page (like Rob suggests) that posts back until the response is ready. Or you might want to look into AJAX to do something similar.

Sign up to request clarification or add additional context in comments.

Comments

1

I've not really had to face this issue too much yet myself, so please keep that in mind.

Is there not anyway you can run the process async and specify a callback method to occur once complete, and then keep the page in a "we are processing your request.." loop cycle. You could then open this up to add some nice UI enhancements as well.

Just kinda thinking out loud. That would probably be the sort of thing I would like to do :)

1 Comment

could you please elaborate this ideea, how do you set the callback method?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.