title: .NET HttpClient: How to set the request method dynamically?
body: <p>How can one use HttpClient and set the method dynamically without having to do something like:</p>
  
  <pre><code>    public async Task&lt;HttpResponseMessage&gt; DoRequest(string url, HttpContent content, string method)
      {
          HttpResponseMessage response;
  
          using (var client = new HttpClient())
          {
              switch (method.ToUpper())
              {
                  case "POST":
                      response = await client.PostAsync(url, content);
                      break;
                  case "GET":
                      response = await client.GetAsync(url);
                      break;
                  default:
                      response = null;
                      // Unsupported method exception etc.
                      break;
              }
          }
  
          return response;
      }
  </code></pre>
  
  <p>At the moment it looks like you would have to use:</p>
  
  <pre><code>HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
  req.Method = "POST";
  </code></pre>