Page view counter

Error: String was not recognized as a valid DateTime

Rate It (1)

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

Sort Posts:

  • Error: String was not recognized as a valid DateTime

    08-20-2004, 10:02 AM
    • Loading...
    • Edoode
    • Joined on 03-17-2004, 11:09 AM
    • The Netherlands
    • Posts 12
    • Points 51
    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
    • Loading...
    • grant
    • Joined on 06-25-2002, 10:21 PM
    • NYC, NY
    • Posts 185
    • Points 925
    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
    • Loading...
    • Edoode
    • Joined on 03-17-2004, 11:09 AM
    • The Netherlands
    • Posts 12
    • Points 51
    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
    • Loading...
    • Edoode
    • Joined on 03-17-2004, 11:09 AM
    • The Netherlands
    • Posts 12
    • Points 51
    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
    • Loading...
    • nthillaiarasu
    • Joined on 07-02-2006, 4:34 PM
    • Bangalore
    • Posts 9
    • Points 6

    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

    10-30-2008, 3:41 AM
    • Loading...
    • dipudew
    • Joined on 10-07-2008, 12:52 PM
    • Posts 8
    • Points 4

     

    hi...N.ThillaiArasu

    thankz...nice post...really helpful in converting text to date type....

     

    dew

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

    11-05-2008, 7:54 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 11,234
    • Points 57,365

    >thankz...nice post...really helpful in converting text to date type....

    Excellent! Please mark the post as answered.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Error: String was not recognized as a valid DateTime

    04-20-2009, 5:04 PM
    • Loading...
    • lordvegeta84
    • Joined on 04-20-2009, 5:02 PM
    • Posts 1
    • Points 2

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

     

Page 1 of 1 (8 items)