回答
我認爲你要找的是ScriptTimeout
。您可以像這樣設置頁面內容:
Page.Server.ScriptTimeout = 60;
超時值以秒爲單位。
另外,請注意,如果您在調試模式下運行,則會被忽略,並且超時設置爲最大值;無論如何,我認爲這不是一個問題,因爲你會增加暫停時間,而不是減少它。
爲我工作。我不得不增加'maxRequestLength'以返回一個大文件。它位於'Web.config',節system.web,就在默認的ScriptTimeout旁邊:'
[This](http://stackoverflow.com/a/20901670/845584)建議ScriptTimeout是經典的ASP,'ExecutionTimeout'代替它,但似乎你不能在頁面級別設置後者,所以這似乎有點遺留黑客? (也[這裏](http://stackoverflow.com/a/29754/845584))。 – PeterX 2015-03-03 07:50:02
按this page,我可以確認太多,要實現這另一個好辦法就是把它添加到您的配置的configSection
:
<location path="~/MyPage.aspx">
<system.web>
<httpRuntime executionTimeout="600"/>
</system.web>
</location>
然後,您可以還添加其他屬性,如maxRequestLength="204800"
或其他部分,像:
<location path="~/MyPage.aspx">
<system.web>
<httpRuntime executionTimeout="6000" maxRequestLength="204800" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="209715200" />
</requestFiltering>
</security>
</system.webServer>
</location>
希望這會有所幫助。
增加超時時間?你的意思是*減少*它?要增加頁面加載所用的時間,可以始終使用Thread.Sleep(http://msdn.microsoft.com/zh-cn/library/d00bd51t.aspx)。 – 2010-06-24 09:33:57