Httpruntime- ExecutionTimeOut

Whiz Kid picture Whiz Kid · Jul 29, 2013 · Viewed 7.6k times · Source

I'm getting timeout error while importing large number of fields from CSV file. While importing it refers the timeout which is configured in

We cannot predict the number of fields from CSV file, some times a large number files will be processing in live environment. I wanted to set Maximum time out in this import logic until it reaches the end of the file. Our client will not mind the time which we configured for import logic, our goal should import all the fileds without time out error.

In googling, I found that we can set a timeout through the following statement with the specified duration,

HttpContext.Current.Server.ScriptTimeout = 360;

But we cannot predict the time which required for importing the large CSV file. How we can configure the maximum timeout through C# code, instead of setting through web.config.

Thanks in Advance!!

Answer

Elyas Dolatabadi picture Elyas Dolatabadi · Feb 19, 2014

Use this Code in Web.config file to Increase ExecutionTimeOut:

<httpRuntime targetFramework="4.5.1" maxRequestLength="2097151" useFullyQualifiedRedirectUrl="true"         executionTimeout="14400" />