Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change a webpage timeout threshold in ASP.NET for a single page?

We've got a report that is being generated and served in real time when a user clicks on a link.

Of course, after we go live, we've discovered that some users have enough data to cause the report to run slowly enough that there is a timeout.

Longer term, we'll solve this by just creating a page that looks for the completed report periodically, and loads it up when it's ready. But for now, if it's possible, we'd like a quick fix to solve the immediate problem.

Is there a way to extend the timeout period for the single webpage being served up?

I found this which seemed to indicate it was sort of possible (but which seems like a very bad idea, because it changes the entire website for the duration of the web call, and worse, it seems like it might have problems with multiple hit synchronization as well, possibly leaving the longer timeout on for the entire site)

I also found this locally, but it didn't end up answering the question (though it did offer the longer term solution that we'll be moving toward.)

like image 717
Beska Avatar asked Feb 10 '10 17:02

Beska


1 Answers

If the page is in (or can be moved to) its own directory, you can put a web.config in that directory with just the executionTimeout or any other settings you want to extend. I.e.

<?xml version="1.0"?>
<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
      <!-- allow for intensive calculations in reports -->
      <httpRuntime executionTimeout="6000" /> 
    </system.web>
</configuration>

According to one of the commenters on the first link you provided, setting Server.ScriptTimeout = 3600; is not a global change, so you may want to reconsider that option as well.

Gerald wrote re: Timeout of an ASP.NET page
on Wed, Nov 29 2006 3:38 PM
I decided to check the validity of this by writing a test program containing two pages. In one of the pages I am setting the ScriptTimeout property to 3000, while in the other page the value of the property is not changed. It turns out that after loading the first page, then the second page, the value of the ScriptTimeout in the second page is reverted to its default value (90 seconds for release, 30000000 for debug) or the value set in the configuration files. In conclusion, the ScriptTimeout property, when changed in one page, does not change at a Global level.

like image 99
jball Avatar answered Oct 25 '22 18:10

jball