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,185
  • 1
  • 12
  • 23
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
  • 16,193
  • 8
  • 71
  • 124
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
  • 330,812
  • 81
  • 665
  • 668