title: sending POST request to the server with AFNetworking returns internal server error (500)
body: <p>I have created a web service with ASP.NET Web Api and trying to send post request to this restful web api using AFNetworking 2. </p>
  
  <p>When I send post request to my local server in IIS and debug using visual studio 2012 every things works well and i get 204 response.</p>
  
  <p>but when I upload the web api application to the server and sen POST request I get internal server error (500)</p>
  
  <p>here is how I send POST request:</p>
  
  <pre><code>static NSString * const BaseURLString = @"http://webapi.r2gblog.ir/";
  NSURL *baseURL = [NSURL URLWithString:BaseURLString];
  AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL];
  
  manager.requestSerializer = [AFJSONRequestSerializer serializer];
  manager.responseSerializer = [AFJSONResponseSerializer serializer];
  
  //Indicationg this device is online and sending its dEVICE token to the server
  Device *device = [Device new];
  
  device.IsOnline = @"True";
  //updating current active users of this app in the server
  NSDictionary *dictionary = [[NSDictionary alloc]initWithObjectsAndKeys:
                              device.DeviceToken,@"DeviceToken",
                              device.IsOnline,@"IsOnline",
                              device.LastActivityDate,@"LastActivityDate",
                              device.DeviceModel,@"DeviceModel",
                              nil];
  
  [manager POST:@"api/iosAppStats" parameters:dictionary success:^(NSURLSessionDataTask *task, id responseObject) {
      NSLog(@"%@",responseObject);
  
  } failure:^(NSURLSessionDataTask *task, NSError *error) {
      NSLog(@"%@",error);
  }];
  </code></pre>
  
  <p>the error message:</p>
  
  <pre><code>Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: internal server error (500)" UserInfo=0x175884d0 {NSErrorFailingURLKey=http://webapi.r2gblog.ir/api/iosAppStats, AFNetworkingOperationFailingURLResponseErrorKey=&lt;NSHTTPURLResponse: 0x17592e90&gt; { URL: http://webapi.r2gblog.ir/api/iosAppStats } { status code: 500, headers {
  "Cache-Control" = "no-cache";
  "Content-Length" = 0;
  Date = "Tue, 01 Apr 2014 20:10:09 GMT";
  Expires = "-1";
  Pragma = "no-cache";
  Server = "Microsoft-IIS/7.5";
  "X-AspNet-Version" = "4.0.30319";
  "X-Powered-By" = "ASP.NET";
  "X-Powered-By-Plesk" = PleskWin;
  } }, NSLocalizedDescription=Request failed: internal server error (500)}
  </code></pre>
  
  <p>I have a controller in my WebApi named "iosAppStatsController" with one method:</p>
  
  <pre><code>// POST api/stats
          public void Post(Device device)
          {
             .
             .
             .
          }
  </code></pre>
  
  <p>and in my webApiConfig.cs which is located in App_start
  I have added this which causes all the responses be in json format:</p>
  
  <pre><code>var json = config.Formatters.JsonFormatter;
          json.SerializerSettings.Converters = new List&lt;JsonConverter&gt;() { new GuidRefJsonConverter() };
          json.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
          config.Formatters.Remove(config.Formatters.XmlFormatter);
  </code></pre>
  
  <p>POST request raw text captured using fiddler 2:</p>
  
  <pre><code>POST http://webapi.r2gblog.ir/api/iosAppStats HTTP/1.1
  Host: webapi.r2gblog.ir
  Connection: keep-alive
  Accept: */*
  Accept-Encoding: gzip, deflate
  Content-Length: 194
  Content-Type: application/json; charset=utf-8
  Accept-Language: en;q=1
  Connection: keep-alive
  User-Agent: Apper/1.0 (iPhone; iOS 7.0.4; Scale/2.00)
  
  {"DeviceToken":"1234567890","LastActivityDate":"2014-04-02T00:40:12.605+0430","IsOnline":"True","OSVersion":"7.0.4","DeviceModel":"iPhone4"}
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>HTTP/1.1 500 Version string portion was too short or too long.
  Cache-Control: no-cache
  Pragma: no-cache
  Expires: -1
  Server: Microsoft-IIS/7.5
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  X-Powered-By-Plesk: PleskWin
  Date: Tue, 01 Apr 2014 20:10:09 GMT
  Content-Length: 0
  </code></pre>
  
  <p>does anyone have any idea why I get this internal server error 500 when I deploy my app to the server?</p>