omega
omega

Reputation: 43893

How to get the maximum http request length time?

In my asp.net/c# website, I make a request that takes like a minute, and sometimes it goes into an error saying the request timed out, and I can't catch it. But I thought of a work around.

I could get the maximum time as a value, then while doing the loop, I can time it, and if it goes past the max amount of time minus 4 seconds, then stop the loop.

But how can I get the maximum time (from web.config file)? Is there a variable I can use?

Thanks

Upvotes: 3

Views: 1868

Answers (2)

Tys
Tys

Reputation: 3610

Perhaps this can help you to get the value you are looking for:

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.timeout%28v=vs.100%29.aspx

Another, easier way is to read the config directly:

HttpRuntimeSection section = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection;

lblDebug.Text = section.MaxRequestLength.ToString();

Upvotes: 0

OnoSendai
OnoSendai

Reputation: 3970

I do think you may check the HttpServerUtility.ScriptTimeout property - it reflects the web.config value for the executionTimeout attribute on httpRuntime element.

MSDN entry on this:

http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.scripttimeout.aspx

Hope it helps!

Upvotes: 1

Related Questions