Bizzare HttpWebResponse Error: ServerProtocolViolation
I have tried everything and I can not figure out why this error happens.

**Background**:
I have an IPad application, written in MonoTouch and I have a thread that runs in the background, and every 15 seconds I sync data with the server. This works the first few iterations of the thread, but eventually I get the following stack trace.

I am talking to an **IIS webserver** with default configuration.

    An exception occured: System.Net.WebException: Error getting response stream (ReadDone4): ServerProtocolViolation ---> System.FormatException: Input string was not in the correct format
      at System.UInt32.Parse (System.String s) [0x00010] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/UInt32.cs:405 
      at System.Net.WebConnection.GetResponse (System.Byte[] buffer, Int32 max) [0x000ba] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnection.cs:565 
      at System.Net.WebConnection.ReadDone (IAsyncResult result) [0x00095] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnection.cs:446 
      --- End of inner exception stack trace ---
      at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x0005e] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:819 
      at System.Net.HttpWebRequest.GetResponse () [0x0000e] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:827 
      at SyncService.REST.RestClient.Execute[IEnumerable`1] (SyncService.REST.RestRequest request) [0x00079] in /Users/Chris/Compass/SyncService/REST/RestClient.cs:42 

Here is the method I am calling:

    public RestResponse<T> Execute<T>(RestRequest request){
        var restResponse = new RestResponse<T>();
        var serializer = new JavaScriptSerializer();
        var urlPath = _baseUrl + "/" + request.Resource;
        var httpRequest = (HttpWebRequest)HttpWebRequest.Create(new Uri(urlPath));
    
        httpRequest.Headers = request.Headers;
        Authenticator.Authenticate(httpRequest);
    
        httpRequest.Method = request.Method.ToString();
        if (request.Method == Method.POST)
            SetPostData(httpRequest, request);
    
        HttpWebResponse httpResponse = null;
        try{
            httpResponse = (HttpWebResponse) httpRequest.GetResponse();
            var reader = new StreamReader(httpResponse.GetResponseStream());
            var responseString = reader.ReadToEnd();
            reader.Close();
            restResponse.StatusCode = httpResponse.StatusCode;
            restResponse.Headers = httpResponse.Headers;
            restResponse.Data = serializer.Deserialize<T>(responseString);
            restResponse.ResponseStatus = ResponseStatus.Completed;
        } 
        catch(WebException e){
            
            restResponse.ResponseStatus = ResponseStatus.Error;
            restResponse.ErrorMessage = e.Message;
            restResponse.ErrorException = e;
            var webResponse = (HttpWebResponse) e.Response;
    		if (webResponse != null){
            	restResponse.StatusCode = webResponse.StatusCode;
            	restResponse.Headers = webResponse.Headers;
    		}
    		if (restResponse.StatusCode != HttpStatusCode.NotModified)
                Console.WriteLine("An exception occured: " + e + "\r\n");
        }catch (Exception ex) {
            restResponse.ResponseStatus = ResponseStatus.Error;
            restResponse.ErrorMessage = ex.Message;
            restResponse.ErrorException = ex;
        }
    
        if (httpResponse != null) 
            httpResponse.Close();
        
        return restResponse;
    }
Please help. I don't know what to do. Google shows nothing,

Bizzare HttpWebResponse Error: ServerProtocolViolation
===

I have tried everything and I can not figure out why this error happens.

**Background**:
I have an IPad application, written in MonoTouch and I have a thread that runs in the background, and every 15 seconds I sync data with the server. This works the first few iterations of the thread, but eventually I get the following stack trace.

I am talking to an **IIS webserver** with default configuration.

    An exception occured: System.Net.WebException: Error getting response stream (ReadDone4): ServerProtocolViolation ---> System.FormatException: Input string was not in the correct format
      at System.UInt32.Parse (System.String s) [0x00010] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/UInt32.cs:405 
      at System.Net.WebConnection.GetResponse (System.Byte[] buffer, Int32 max) [0x000ba] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnection.cs:565 
      at System.Net.WebConnection.ReadDone (IAsyncResult result) [0x00095] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnection.cs:446 
      --- End of inner exception stack trace ---
      at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x0005e] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:819 
      at System.Net.HttpWebRequest.GetResponse () [0x0000e] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:827 
      at SyncService.REST.RestClient.Execute[IEnumerable`1] (SyncService.REST.RestRequest request) [0x00079] in /Users/Chris/Compass/SyncService/REST/RestClient.cs:42 

Here is the method I am calling:

    public RestResponse<T> Execute<T>(RestRequest request){
        var restResponse = new RestResponse<T>();
        var serializer = new JavaScriptSerializer();
        var urlPath = _baseUrl + "/" + request.Resource;
        var httpRequest = (HttpWebRequest)HttpWebRequest.Create(new Uri(urlPath));
    
        httpRequest.Headers = request.Headers;
        Authenticator.Authenticate(httpRequest);
    
        httpRequest.Method = request.Method.ToString();
        if (request.Method == Method.POST)
            SetPostData(httpRequest, request);
    
        HttpWebResponse httpResponse = null;
        try{
            httpResponse = (HttpWebResponse) httpRequest.GetResponse();
            var reader = new StreamReader(httpResponse.GetResponseStream());
            var responseString = reader.ReadToEnd();
            reader.Close();
            restResponse.StatusCode = httpResponse.StatusCode;
            restResponse.Headers = httpResponse.Headers;
            restResponse.Data = serializer.Deserialize<T>(responseString);
            restResponse.ResponseStatus = ResponseStatus.Completed;
        } 
        catch(WebException e){
            
            restResponse.ResponseStatus = ResponseStatus.Error;
            restResponse.ErrorMessage = e.Message;
            restResponse.ErrorException = e;
            var webResponse = (HttpWebResponse) e.Response;
    		if (webResponse != null){
            	restResponse.StatusCode = webResponse.StatusCode;
            	restResponse.Headers = webResponse.Headers;
    		}
    		if (restResponse.StatusCode != HttpStatusCode.NotModified)
                Console.WriteLine("An exception occured: " + e + "\r\n");
        }catch (Exception ex) {
            restResponse.ResponseStatus = ResponseStatus.Error;
            restResponse.ErrorMessage = ex.Message;
            restResponse.ErrorException = ex;
        }
    
        if (httpResponse != null) 
            httpResponse.Close();
        
        return restResponse;
    }
Please help. I don't know what to do. Google shows nothing,
