views:

39

answers:

3

Hi,

I build a website, that:

  • reads data from a website by HttpWebRequest
  • Sort all Data
  • Parse values of the data
  • and give out newly

On local server it works perfect, but when I push it to my live server, the double.Parse fails with an error.

So: - how to track what the double.parse is trying to parse? - how to debug live server?

Lang is ASP.Net / C#.net 2.0

+4  A: 

You probably have culture issues.

Pass CultureInfo.InvariantCulture to double.Parse and see if it helps.

To see the exception on the server, add <customErrors mode="Off" /> to the <system.web> element in web.config. (And make sure to remove it afterwords)
Alternatively, you can setup a real error logging system, such as ELMAH, or check the server's event log.

SLaks
It seems right!How can I edit the culture?
Kovu
What do you mean?
SLaks
ok, I changed the cultureinfr allready =)
Kovu
+2  A: 

Sounds like a problem with regional settings and the decimal separator. Might be different in your development/live servers.

naivists
+2  A: 

I would use TryParse instead of just plain Parse. That way, you would control what is being intended to parse.

Like this.

double outval;

if (!double.TryParse(yourvar, out outval)) {
  // throw and manage error on your website
}

// life goes on.
Pablo Santa Cruz
This will not help him solve the problem.
SLaks
How come? He can log the information being parsed and act accordingly. Am I missing something else here?
Pablo Santa Cruz