title: c# redirect post request
body: <p>Trying to make a post request from one application to another using the same Form Data parameters that the first one received.
  both application controller currently have same method:</p>
  <pre><code>public async Task&lt;ActionResult&gt; TestSet()
      {
          var inputString = Request.Form[&quot;inputString&quot;];
          var inputFile = Request.Files[0];
          var resultString = await _service.Set(inputString, inputFile.FileName, inputFile.ContentType, inputFile.InputStream);
          return new MyJsonResult(new
          {
              fileName = resultString
          });
      }
  </code></pre>
  <p>which return json string:</p>
  <pre><code>{&quot;fileName&quot;: &quot;someFileName.png&quot;}
  </code></pre>
  <p>Trying to make the first method to be something like this</p>
  <pre><code>public async Task&lt;ActionResult&gt; TestSet()
      {
          var inputString = Request.Form[&quot;inputString&quot;];
          var inputFile = Request.Files[0];
          if (!string.IsNullOrEmpty(_redirectUrl))
          {
              using (var client = new HttpClient())
              {
                  HttpContent content = GetContentSomehow(this.Request); // this i have an issue with
                  var response = await client.PostAsync(_redirectUrl, content);
                  var responseString = await response.Content.ReadAsStringAsync();
                  return new MyJsonResult(responseString);
              }
          }
          var resultString = await _service.Set(inputString, inputFile.FileName, inputFile.ContentType, inputFile.InputStream);
          return new MyJsonResult(new
          {
              fileName = resultString
          });
      }
  </code></pre>
  <p><a href="https://stackoverflow.com/a/43248257/1184979">This</a> could help to get ByteArrayContent for File only.</p>
  <p>And this would probably work to get the non-file parameters into StringContent, but how to get both of them into single Content?</p>
  <pre><code>var jsonString = JsonConvert.SerializeObject(Request.Form.ToDictionary());
  var content = new StringContent(jsonString, Encoding.UTF8, &quot;application/json&quot;);
  </code></pre>