LoginSignup
0
2

More than 5 years have passed since last update.

ASP.NET でスクリプト単位でタイムアウト設定(executionTimeout)を変更する

Posted at

簡単に言うと

サブディレクトリを切ってその中に対象のスクリプトと Web.config を入れます。

app_root
|   Web.config
|   
\---slow_scripts
        Web.config

ASP.NET では動的にタイムアウト値を変更できない

PHP には set_time_limit() という関数があります。スクリプト単位で簡単にタイムアウト値を変更できますが、ASP.NET では Web.config でアプリケーション全体で1つの設定という感じになっています。

サブディレクトリで設定を変える

ただしサブディレクトリを作り、その中に Web.config を入れれば、アプリケーション全体の設定の一部を上書きすることができます。その上書きされた設定はサブディレクトリ配下全体に適用されます。

これを利用することで、アプリケーション全体の設定はそのままに、特定のスクリプト(Web フォーム)だけタイムアウト値を変更することが出来ます。

Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
      <httpRuntime
        executionTimeout="300"
      />
    </system.web>
</configuration>

手間はかかりますが、スクリプトごとにサブディレクトリを作ればスクリプトごとに値を調整することもできます。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2