I have a web application that passes a DateTime from one page to another through the query string. It was working just fine in both IE and FireFox, but was throwing exceptions whenever I tried it in Google Chrome. The program is choking on the following line:
startDateTime = Convert.ToDateTime(Request.QueryString["start"]);
So, I ran the debugger and found that the value in the query string is:
Wed Oct 03 2012 08:00:00 GMT-0400 (Eastern Daylight Time)
I concluded that Convert just wasn't up to the job and set about trying to get DateTime.ParseExact to tame this beast. But, so far the correct format string has eluded me. Here's the code that I've been trying (which doesn't work):
DateTime.ParseExact(Request.QueryString["start"], "ddd MMM dd yyyy HH:mm:ss zzz", CultureInfo.InvariantCulture);
This page is being called from another page through some JavaScript that is called by a third-party component (DayPilotCalendar). Here is the relevant property that is set on the DayPilotCalendar control:
TimeRangeSelectedJavaScript="GB_showPage('Request Magnet Time', '../../../EventAddEdit.aspx?start=' + encodeURIComponent(start) + '&end=' + encodeURIComponent(end))"
What is wrong with my format string?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…