为什么服务器使用一段时间,我的网站浏览网页的时候就会出现String was not recognized as a valid DateTime 的错误?然后我重启下IIS,就会好上一段时间,这个时间可能是几小时,也可能是几天。百度了下都说是时间设置问题,按照百度上说的把时间设置了一遍也无法解决,我觉得不是时间设置问题,如果时间设置有问题,那应该是直接就会出现这个错误,而不是隔段时间出现。大神们有遇到这个问题的吗?请帮助解决下

解决方案 »

  1.   

    时间转换出错,看看具体的错误提示,找到代码,分析bug原因
      

  2.   

    我怀疑不是时间设置问题,因为是隔段时间才出现的。重启IIS又正常了
      

  3.   

    重启下IIS 治标不治本
    关键看错误出在哪
    把网页调试打开
    如果有错误,网页上会显示出错的源代码处
      

  4.   

    你不会是使用了静态变量,导致时间参数超顶了,例如new datetime("10000-9-29")
      

  5.   


    String was not recognized as a valid DateTime. 
     Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.  Exception Details: System.FormatException: String was not recognized as a valid DateTime.Source Error: 
     An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
    Stack Trace: [FormatException: String was not recognized as a valid DateTime.]
       System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +2271682
       System.DateTime.Parse(String s) +22
       KeLin.ClassManager.DAL.class_DAL.GetModel(Int64 siteid, Int64 classid) +2630
       KeLin.ClassManager.Tool.WapTool.getClassInfo(String siteid, String classid) +82
       KeLin.WebSite.PageWap.a(Object A_0, EventArgs A_1) +15207
       System.EventHandler.Invoke(Object sender, EventArgs e) +0
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
      

  6.   

    [FormatException: String was not recognized as a valid DateTime.]
       System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +2271682
       System.DateTime.Parse(String s) +22

       KeLin.ClassManager.DAL.class_DAL.GetModel(Int64 siteid, Int64 classid) +2630
       KeLin.ClassManager.Tool.WapTool.getClassInfo(String siteid, String classid) +82

       KeLin.WebSite.PageWap.a(Object A_0, EventArgs A_1) +15207
       System.EventHandler.Invoke(Object sender, EventArgs e) +0
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061写的明明白白,非要说是iis的问题。如果说iis报一堆完全不着调的东西么,你说是iis的问题还能说过去,你这里都出现[FormatException: String was not recognized as a valid DateTime.]
       System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +2271682
       System.DateTime.Parse(String s) +22
       KeLin.ClassManager.DAL.class_DAL.GetModel(Int64 siteid, Int64 classid) +2630
       KeLin.ClassManager.Tool.WapTool.getClassInfo(String siteid, String classid) +82
       KeLin.WebSite.PageWap.a(Object A_0, EventArgs A_1) +15207
       System.EventHandler.Invoke(Object sender, EventArgs e) +0
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061, KeLin.ClassManager.DAL.class_DAL.GetMode
    还要硬说是IIS的问题,这个锅微软不背
      

  7.   


    我没说是IIS问题啊,我只是说重启下IIS就好了。我是想问这个到底是什么问题?要怎么解决?
      

  8.   

     System.DateTimeParse.Parse
     KeLin.ClassManager.DAL.class_DAL.GetModel(Int64 siteid, Int64 classid) +2630
       KeLin.ClassManager.Tool.WapTool.getClassInfo(String siteid, String classid) +82
    已经帮你标出了,版主让你调整系统的区域选项,无效回答。OnLoad--------》ClassInfo---------》DAL.GetModel---------》DateTimeParse.Parse详细看为啥如此,调整系统的区域选项,是无效回答
      

  9.   

       KeLin.ClassManager.DAL.class_DAL.GetModel(Int64 siteid, Int64 classid) +2630
       KeLin.ClassManager.Tool.WapTool.getClassInfo(String siteid, String classid) +82    这一句提示了System.DateTimeParse.Parse   看下这块啊。 很明显的
      

  10.   

    你应该把时间在
    static ExJsonConvert()
            {
                TimeFormat = new IsoDateTimeConverter
                {
                    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"            };
            }
    转换一下
      

  11.   

    很明显是DateTime.Parse的时候出错  你分析下这块代码的时间格式    最后做一下判断或者格式化处理即可。