title: How can the error 'Client found response content type of 'text/html'.. be interpreted
body: <p>I'm using C# and connecting to a WebService via an auto-generated C# proxy object. The method I'm calling can be long running, and sometimes times out. I get different errors back, sometimes I get a <code>System.Net.WebException</code> or a <code>System.Web.Services.Protocols.SoapException</code>. These exceptions have properties I can interrogate to find the specific type of error from which I can display a human-friendly version of to the user.</p>
  
  <p>But sometimes I just get an <code>InvalidOperationException</code>, and it has the following Message. Is there any way I can interpret what this is without digging through the string for things I recognize, that feels very dirty, and isn't internationalization agnostic, the error message might come back in a different language.</p>
  
  <pre><code>Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.
  The request failed with the error message:
  --
  &lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;Request timed out.&lt;/title&gt;
                          &lt;style&gt;
           body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
           p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
           b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
           H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
           H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
           pre {font-family:"Lucida Console";font-size: .9em}
           .marker {font-weight: bold; color: black;text-decoration: none;}
           .version {color: gray;}
           .error {margin-bottom: 10px;}
           .expandable { text-decoration:underline; font-weight:bold;     color:navy;         cursor:hand; }
          &lt;/style&gt;
      &lt;/head&gt;
  
      &lt;body bgcolor="white"&gt;
  
              &lt;span&gt;&lt;H1&gt;Server Error in '/PerformanceManager' Application.&lt;hr     width=100% size=1 color=silver&gt;&lt;/H1&gt;
  
              &lt;h2&gt; &lt;i&gt;Request timed out.&lt;/i&gt; &lt;/h2&gt;&lt;/span&gt;
  
              &lt;font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "&gt;
  
              &lt;b&gt; Description: &lt;/b&gt;An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  
              &lt;br&gt;&lt;br&gt;
  
              &lt;b&gt; Exception Details: &lt;/b&gt;System.Web.HttpException: Request timed out.&lt;br&gt;&lt;br&gt;
  
              &lt;b&gt;Source Error:&lt;/b&gt; &lt;br&gt;&lt;br&gt;
  
              &lt;table width=100% bgcolor="#ffffcc"&gt;
                 &lt;tr&gt;
                    &lt;td&gt;
                        &lt;code&gt;
  
  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.&lt;/code&gt;
  
                    &lt;/td&gt;
                 &lt;/tr&gt;
              &lt;/table&gt;
  
              &lt;br&gt;
  
              &lt;b&gt;Stack Trace:&lt;/b&gt; &lt;br&gt;&lt;br&gt;
  
              &lt;table width=100% bgcolor="#ffffcc"&gt;
                     &lt;tr&gt;
                    &lt;td&gt;
                        &lt;code&gt;&lt;pre&gt;
  
  [HttpException (0x80004005): Request timed out.]
  &lt;/pre&gt;&lt;/code&gt;
  
                    &lt;/td&gt;
                 &lt;/tr&gt;
              &lt;/table&gt;
  
              &lt;br&gt;
  
              &lt;hr width=100% size=1 color=silver&gt;
  
              &lt;b&gt;Version Information:&lt;/b&gt; Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833
  
              &lt;/font&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  &lt;!-- 
  [HttpException]: Request timed out.
  --&gt;
  --.
  </code></pre>
  
  <p>Edit:
  I have a try-catch around the method on the web-server. I have debugged it, and the web-server method returns (after a minute or so) without any exception. I also added an unhandled exception handler in the web service and a breakpoint there wasn't hit. As soon as the web-service returns, I get this error in the client instead of the result I expected.</p>