title: Int32.ParseInt throws FormatException after web post
body: <p><strong>Update</strong></p>
  
  <p>I've found the problem, the exception came from a <strong>2nd field</strong> on the same form which indeed should have prompted it (because it was empty)... I was looking at an error which I thought came from trying to parse one string, when in fact it was from trying to parse another string... Sorry for wasting your time.</p>
  
  <p><strong>Original Question</strong></p>
  
  <p>I'm completely dumbfounded by this problem. I am basically running <code>int.Parse("32")</code> and it throws a <code>FormatException</code>. Here's the code in question:</p>
  
  <pre><code>private double BindGeo(string value)
  {
      Regex r = new Regex(@"\D*(?&lt;deg&gt;\d+)\D*(?&lt;min&gt;\d+)\D*(?&lt;sec&gt;\d+(\.\d*))");
      Regex d = new Regex(@"(?&lt;dir&gt;[NSEW])");
      var numbers = r.Match(value);
      string degStr = numbers.Groups["deg"].ToString();
      string minStr = numbers.Groups["min"].ToString();
      string secStr = numbers.Groups["sec"].ToString();
      Debug.Assert(degStr == "32");
      var deg = int.Parse(degStr);
      var min = int.Parse(minStr);
      var sec = double.Parse(secStr);
      var direction = d.Match(value).Groups["dir"].ToString();
      var result = deg + (min / 60.0) + (sec / 3600.0);
      if (direction == "S" || direction == "W") result = -result;
      return result;
  }
  </code></pre>
  
  <p>My input string is <code>"32 19 17.25 N"</code></p>
  
  <p>The above code runs on a .NET 4 web hosting service (aspspider) on an ASP.NET MVC 3 web application (with Razor as its view engine).</p>
  
  <p>Note the assersion of <code>degStr == "32"</code> is valid! Also when I take the above code and run it in a console application it works just fine. I've scoured the web for an answer, nothing...</p>
  
  <p>Any ideas?</p>
  
  <p><strong>UPDATE (stack trace)</strong></p>
  
  <pre><code>[FormatException: Input string was not in a correct format.]
     System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal) +9586043
     System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
     System.Int32.Parse(String s) +23
     ParkIt.GeoModelBinder.BindGeo(String value) in C:\MyProjects\ParkIt\ParkIt\GeoBinder.cs:42
  </code></pre>
  
  <p>Line 42 is <code>var deg = int.Parse(degStr);</code> and note that the exception is in <code>System.Int32.Parse</code> (not in <code>System.Double</code> as was suggested).</p>