ASP.NET ファイルアップロード関連トラブル
ファイルアップロード時、以下のエラーに遭遇
- maxAllowedContentLength エラー
- 要求の長さの最大値を超えました。 POSTされるファイルの最大サイズが引っかかる場合、発生。 maxRequestLengthが足りない場合起きるエラー 大容量のCSVファイルなどは最大容量で引っかかるらしい、 以下の様に、httpRuntimeに最大設定で回避
<system.web> <httpRuntime maxRequestLength="65535"/> </system.web>
IIS7以降ではサーバの要求フィルター設定項目でも、ファイルサイズの 上限を設定する必要がある。らしい
<system.webServer> <modules runAllManagedModulesForAllRequests="true" /> <security> <requestFiltering> <requestLimits maxAllowedContentLength="120000000"/> </requestFiltering> </security> </system.webServer>