Take the 2-minute tour ×

We're running IIS 6.0 on Windows Server 2003. The server is set up as UK English, which may have a bearing. Occasionally after an app pool recycle we'll see the corresponding ASP.NET 2.0 website start to throw errors with the message

String was not recognized as a valid DateTime.

The only way I know to resolve this is to manually recycle the app pool, at which point all is good again.

Is anyone aware of this problem, and any fix (beyond upgrading etc.)?

share|improve this question
where do you see the error? in the event log or on a web page? –  splattne Jun 14 '11 at 9:25
A request is made to the web server. ASP.NET tries to satisfy the request, and in so doing makes a variety of calls to the backend SQL Server 2005 database. Some of these calls fail when they try to convert what they're getting from the DB to a valid DateTime, and ASP.NET generates this error. I recall looking briefly at which dates trigger the error, but there didn't seem to be an obvious pattern. Not anything like a confusion between US and UK dates, I don't think. –  Yellowfog Jun 14 '11 at 10:46

3 Answers 3

If you see the error in the event log, it's probably an application error because the current thread's culture is not set yet.

You could try to insert/change this entry in the your application's web.config:

<globalization uiCulture="en" culture="en-US" />

makesure you test it in a staging area before deploying it.

share|improve this answer
presumably I'd need GB rather than US. But does my response to your comment against the question mean that this is not the source of the problem? –  Yellowfog Jun 14 '11 at 10:48
@Yellowfog My question was, if you saw the error message in your web browser or in the server's event log. maybe there is a startup procedure (global.asax for example) which causes the error) –  splattne Jun 14 '11 at 10:56
Well, I see the error in both, because the error's unhandled. But it's not a startup procedure that's throwing the error, it traces back to a call made in Page.Load. –  Yellowfog Jun 14 '11 at 11:12
So, then it's an application error: your app implictly converts a string type into a DateTime using the wrong culture in the executing process thread. Try to look at the source code line (if it's part of your code). –  splattne Jun 14 '11 at 11:15
I'm not sure what I'm looking for. This is code that works normally, and starts failing (for the same inputs from the DB) only when an app pool recycle happens, and then only infrequently. So if the code is staying the same, and the inputs to the functions are staying the same, it looks like something is odd is happening to the application pool. On the other hand, it does seem like a difference in culture is likely to be implicated. So I guess I'll try to trap the error and inspect the thread culture for the next occurrence. –  Yellowfog Jun 14 '11 at 11:36

Sounds like it could be VarConversionLocaleSetting. (shakes fist at varconversionlocalesetting)


share|improve this answer
Intriguing. I can't find enough about it by aimlessly Googling however (shakes fist at own ignorance). The KB in question also says that it applies to 2000 rather than 2003. So... it may be that I can get work to talk to Microsoft and resolve the question that way. –  Yellowfog Jun 14 '11 at 15:56
Definitely. It works the same way in later versions. –  TristanK Jun 14 '11 at 22:25

I've seen this on multiple 2003 servers in a farm too (only occurring on an odd one and not usually more than once a week), but have never been able to get to the bottom of it, we resorted to adding automated checks and re-recycling.

share|improve this answer

Your Answer


