title: Get Content-Disposition parameters
body: <p>How do I get Content-Disposition parameters I returned from WebAPI controller using WebClient?</p>
  
  <p>WebApi Controller</p>
  
  <pre><code>    [Route("api/mycontroller/GetFile/{fileId}")]
      public HttpResponseMessage GetFile(int fileId)
      {
          try
          {
                  var file = GetSomeFile(fileId)
  
                  HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                  response.Content = new StreamContent(new MemoryStream(file));
                  response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
                  response.Content.Headers.ContentDisposition.FileName = file.FileOriginalName;
  
                  /********* Parameter *************/
                  response.Content.Headers.ContentDisposition.Parameters.Add(new NameValueHeaderValue("MyParameter", "MyValue"));
  
                  return response;
  
          }
          catch(Exception ex)
          {
              return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
          }
  
      }
  </code></pre>
  
  <p>Client</p>
  
  <pre><code>    void DownloadFile()
      {
          WebClient wc = new WebClient();
          wc.DownloadDataCompleted += wc_DownloadDataCompleted;
          wc.DownloadDataAsync(new Uri("api/mycontroller/GetFile/18"));
      }
  
      void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
      {
          WebClient wc=sender as WebClient;
  
          // Try to extract the filename from the Content-Disposition header
          if (!String.IsNullOrEmpty(wc.ResponseHeaders["Content-Disposition"]))
          {
             string fileName = wc.ResponseHeaders["Content-Disposition"].Substring(wc.ResponseHeaders["Content-Disposition"].IndexOf("filename=") + 10).Replace("\"", ""); //FileName ok
  
          /******   How do I get "MyParameter"?   **********/
  
          }
          var data = e.Result; //File OK
      }
  </code></pre>
  
  <p>I'm returning a file from WebApi controller, I'm attaching the file name in the response content headers, but also I'd like to return an aditional value. </p>
  
  <p>In the client I'm able to get the filename, but <strong>how do I get the aditional parameter?</strong></p>