設(shè)置ASP.NET頁面的運(yùn)行超時(shí)時(shí)間詳細(xì)到單個(gè)頁面及站點(diǎn)

字號(hào):


    全局超時(shí)時(shí)間
    服務(wù)器上如果有多個(gè)網(wǎng)站,希望統(tǒng)一設(shè)置一下超時(shí)時(shí)間,則需要設(shè)置 Machine.config 文件中的 ExecutionTimeout 屬性值。
    Machine.config 文件位于 %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ 目錄中。
    例如:
    代碼如下:
    <httpRuntime executionTimeout="90" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
    單個(gè)站點(diǎn)超時(shí)時(shí)間
    Web.config配置文件中設(shè)置http請(qǐng)求運(yùn)行時(shí)間:
    代碼如下:
    system.web>
    <httpRuntime maxRequestLength="102400" executionTimeout="720" />
    </system.web>
    這里設(shè)置的為720秒,前面的屬性maxRequestLength一般用于用戶上傳文件限制大??!默認(rèn)一般為4096 KB (4 MB)。
    單個(gè)頁面請(qǐng)求超時(shí)時(shí)間
    對(duì)于單個(gè)頁面,可以使用Server.ScriptTimeout來設(shè)定超時(shí)。
    Server.ScriptTimeout = 120;
    注意:如果在Web.config里設(shè)置了debug屬性,例如:<compilation debug="true" targetFramework="4.0">
    此時(shí),ScriptTimeout會(huì)被忽略。