Error: String was not recognized as a valid DateTime

Rate It (1)

Last post 04-20-2009 5:04 PM by lordvegeta84. 5 replies.

Sort Posts:

  • Error: String was not recognized as a valid DateTime

    08-20-2004, 10:02 AM
    • Member
      51 point Member
    • Edoode
    • Member since 03-17-2004, 11:09 AM
    • The Netherlands
    • Posts 12
    Hi,

    I'm running an unmodified dotText latest version on a Windows2003 server. Whenever I click on a 'monthly archive' link I receive the error 'String was not recognized as a valid DateTime.' An example URL is http://blog.swiftalpha.com/archive/2004/07.aspx

    The server is configured to use the English regional settings. The web.config reads '<globalization culture="en-US" />' as expected. I've looked around for a solution but didn't find one.

    Anyone?

    -Edo

    Swords don't run out of ammo
  • Re: Error: String was not recognized as a valid DateTime

    08-20-2004, 1:01 PM
    • Participant
      925 point Participant
    • grant
    • Member since 06-25-2002, 10:21 PM
    • NYC, NY
    • Posts 185
    In your web.config, search for a line containing ArchiveMonth in the HttpHandlers section.

    What is that line?

    Should be

    <HttpHandler pattern = "/archive/\d{4}/\d{1,2}\.aspx$" controls = "ArchiveMonth.ascx" />


    Typically this is related to a globalization issue. I would also just double check that (but it also looks less likely that that's the issue since your daily archive pages pass dateformat muster).

    Can you turn off custom exceptions and post the full exception with code lines/stack?
    I'm Idaho!
  • Re: Error: String was not recognized as a valid DateTime

    08-20-2004, 3:33 PM
    • Member
      51 point Member
    • Edoode
    • Member since 03-17-2004, 11:09 AM
    • The Netherlands
    • Posts 12
    Hi,

    thanks for the reply.

    Web.config reads:
    <HttpHandler pattern = "^(?:/archive/\d{4}/\d{1,2}\.aspx)$" controls = "ArchiveMonth.ascx" />

    Stack Trace:


    [FormatException: String was not recognized as a valid DateTime.]
    System.DateTime.ParseExact(String s, String[] formats, IFormatProvider provider, DateTimeStyles style) +106
    Dottext.Framework.Util.WebPathStripper.GetDateFromRequest(String uri, String archiveText) +164
    Dottext.Web.UI.Controls.ArchiveMonth.OnLoad(EventArgs e) +61
    System.Web.UI.Control.LoadRecursive() +35
    ....
    System.Web.UI.Page.ProcessRequestMain() +731

    I've checked globalisation settings, it all seems in order.

    Grt,

    -Edo
    Swords don't run out of ammo
  • Re: Error: String was not recognized as a valid DateTime

    08-20-2004, 5:10 PM
    • Member
      51 point Member
    • Edoode
    • Member since 03-17-2004, 11:09 AM
    • The Netherlands
    • Posts 12
    Hi,

    After doing some looking around in the code I changed one line in Dottext.Framework.Util.WebPathStripper

    I replaced the private static readonly string[] dateFormats with:

    {"yyyy\\/MM\\/d","yyyy\\/MM\\/dd","yyyy\\/M\\/dd","yyyy\\/M\\/d","yyyy\\/MM","yyyy\\/M"};

    This solved my problem. I only wonder why noone else has it?!?

    Grt,

    -Edo
    Swords don't run out of ammo
  • Re: Error: String was not recognized as a valid DateTime

    11-02-2007, 5:52 AM
    • Member
      6 point Member
    • nthillaiarasu
    • Member since 07-02-2006, 4:34 PM
    • Bangalore
    • Posts 9

    Hi i also had the same problem my applications will be running in localhost but when i use IIS or apache it will throw the error  String was not recognized as a valid DateTime.After a lot of search i finally got the solution

    just declare ur date field as

     

     System.DateTime str_date=DateTime.Parse(sel3.Text,System.Globalization.CultureInfo.CreateSpecificCulture("en-AU").DateTimeFormat);

    I hope it will work fine in ur application

    Thanks in Advance,

    N.ThillaiArasu,

    http://nthillaiarasu.blogspot.com
     

    N.ThillaiArasu
  • Re: Error: String was not recognized as a valid DateTime

    04-20-2009, 5:04 PM
    • Member
      2 point Member
    • lordvegeta84
    • Member since 04-20-2009, 5:02 PM
    • Posts 1

     Where do you find that code?? i have an aplication that dos not run because this error..

     

Page 1 of 1 (6 items)