title: How do I change the http version of my web method call to stop 505 error?
body: <p>I need to get some data from a service provider and have configured our .net app to point to their hosted web service to get the data. Using the code below, when the web method is called (<code>ws.DoTransfer</code>) I get the following error...</p>
  
  <pre><code>    private void DoTransferLocal()
      {
              Version version = new Version();
              string error = string.Empty;
              try
              {
                      RemoteService ws = new RemoteService();
                      ServicePoint spm = ServicePointManager.FindServicePoint(new Uri(ws.Url));
                      spm.Expect100Continue = true;
                      version = spm.ProtocolVersion;
                      ws.Credentials = credentials;
                      ws.PreAuthenticate = true;
                      RemoteResult result = ws.DoTransfer();
                      MessageBox.Show("Result = " + result.transferStatus);
              }
              catch (Exception ex)
              {
                      error = ex.Message;
              }
              finally
              {
                      MessageBox.Show(version.ToString() + Environment.NewLine + error);
              }
      }
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>The request failed with HTTP status 505: HTTP Version Not Supported.</p>
  </blockquote>
  
  <p>I've been told that the version of the HTTP needs to be 1.0, but mine is 1.1</p>
  
  <p>I've read a couple of google posts about this and have seen suggestions to override the <code>GetWebRequest</code> method as shown here...</p>
  
  <pre><code>    protected override System.Net.WebRequest GetWebRequest(Uri uri)
      {   
              System.Net.HttpWebRequest request = base.GetWebRequest(uri) as System.Net.HttpWebRequest;
              request.ProtocolVersion = System.Net.HttpVersion.Version10;
              return request;
      }
  </code></pre>
  
  <p>...but when I try this, the <code>GetWebRequest</code> after <code>base.</code> is underlined in red and has the error...</p>
  
  <blockquote>
    <p>'Object' does not contain a definition for 'GetWebRequest'</p>
  </blockquote>
  
  <p>Can anyone tell me how I change the HTTP version to 1.0, but still use similar code (rather than building up my own soap packets) to call my web method?</p>
  
  <p>I can't seem to find any kind of code that I can simply inject into my code that looks like the following line...</p>
  
  <pre><code>    ws.HttpVersion = HttpVersion.Version10;
  </code></pre>
  
  <p>Thanks</p>