3

I keep getting this exception which happens every other time. For some reason I do not think its my code as it happens on different pages as well. It also happens on pages where I do not have the DateTime object.

In addition the exception window that comes up is different when there is an application exception which goes to a line of code. When this exception happens this is not the case. At the top it says the code stack only contains external code.

The added or subtracted value results in an un-representable DateTime.
 at System.DateTime.op_Addition(DateTime d, TimeSpan t)
 at System.Web.HttpContext.MustTimeout(DateTime utcNow)
 at System.Web.RequestTimeoutManager.RequestTimeoutEntry.TimeoutIfNeeded(DateTime now)
 at System.Web.RequestTimeoutManager.CancelTimedOutRequests(DateTime now)
 at System.Web.RequestTimeoutManager.TimerCompletionCallback(Object state)
 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
 at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
 at System.Threading.TimerQueueTimer.CallCallback()
 at System.Threading.TimerQueueTimer.Fire()
 at System.Threading.TimerQueue.FireNextTimers()
user1253073
  • 374
  • 2
  • 6
  • 26
  • 1
    *For some reason I do not think its my code as it happens on different pages as well* It looks like IIS doing what it normally does and making sure that your request isn't taking longer than the timeout. Have you set the timeout to something like -1 or 999999999? – ta.speot.is Oct 09 '13 at 03:29
  • `web.config` and in other places. – ta.speot.is Oct 09 '13 at 03:33
  • For me that was the issue, timeout in the web.config was out of range. appreciated – Khaled Obaid Sep 22 '20 at 05:27

3 Answers3

1

System.Web.HttpContext.MustTimeout seems to be involved in coordinating request timeouts. To this end, I imagine that...

System.DateTime.op_Addition(DateTime d, TimeSpan t)

...is MustTimeout calculating the instant that a request should timeout. It could do this by adding some timeout value to the request's start time.

Check that you don't have any timeouts (in web.config or otherwise) that are artificially high or invalid. For example:

<system.web>
    <httpRuntime executionTimeout="999999999999" />
</system.web>

Various timeouts are documented in this Stack Overflow answer.

Community
  • 1
  • 1
ta.speot.is
  • 26,914
  • 8
  • 68
  • 96
  • I do have but I want the site to not timeout as users upload files that take a while so I do not want the site to timeout. Also, am I missing something. If its too high then it should not timeout, right? so wht the exception then? – user1253073 Oct 09 '13 at 03:39
  • Your `executionTimeout` is about 9512 years. `DateTime` can represent up to the year `9999`. Add `2013` and `9512` together. IIS can't calculate exactly when the request should timeout. Try setting a timeout that's only 7 millenia long. – ta.speot.is Oct 09 '13 at 03:40
  • One more question. Is this timeout different than the session timeout, how do i set the other then. It seems this timeout is for loading the current request? and the other one I need to set is the one where the session expires. – user1253073 Oct 09 '13 at 03:42
  • There are several timeouts, for connections, requests, sessions (although only for `InProc` and other session state providers that support timeouts), cookies etc. I suggest you figure out which ones you use (you might use cookie-less sessions in which case cookie timeout doesn't matter) and then configuring them sensibly. [But the client browser might enforce its own timeouts, so if your file uploads take too long consider breaking them up](http://support.microsoft.com/kb/181050). – ta.speot.is Oct 09 '13 at 03:44
1

I got the same when i was trying to expires cookies, but now its worked for me :)

HttpCookie cookie = new HttpCookie("appts");
cookie.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie);
Raj kumar
  • 1,275
  • 15
  • 20
0
Max Value 23:59:59.9999999, December 31, 9999,

Min Value  00:00:00.0000000, January 1, 0001.

If your DateTime + TimeSpan< MinValue  Or DateTime + TimeSpan>MaxValue

You will get the exception, make sure you remain in bounds.

Igoy
  • 2,942
  • 22
  • 23