Convert.ToDateTime
uses DateTime.Parse
internally, with the current culture of server. And, the problem is your new server’s current culture’s DateTime
format is different from your string.
You can use DateTime.ParseExact()
instead of this.
Converts the specified string representation of a date and time to its
DateTime equivalent using the specified format and culture-specific
format information. The format of the string representation must match
the specified format exactly.
DateTime.ParseExact(myTextBox.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
solved Convert.ToDateTime Works in console app but errors out in asp.net