0

I am using Visual Studio for a web application and all works fine.

When i publish the solution online i have this exception for this row:

DateTime.Parse(form["dataNotaNuovo"])

The exception text is:

String is not recognized as a valid datetime

Why the problem is only in the online version and not in my local solution?Can it be a .NET version problem?(I don't know .NET server version)

Thanks to all

3 Answers3

0

DateTime.Parse affected by the localization setting of the machine. use DateTime.ParseExact if you know what is the format of the string

Amir Sasson
  • 10,985
  • 1
  • 13
  • 25
0

Your server and client are probably using different locales. Instead make sure the client posts the data in a known format and use DateTime.ParseExact

Peter Morris
  • 20,174
  • 9
  • 81
  • 146
0

Your server probably has different settings for its locale (date and time format). To prevent this, you should always use a specific format and ParseExact. Or mandate and ensure that all computers your code runs on use the same locale.

Joey
  • 344,408
  • 85
  • 689
  • 683