title: How to upload data + multiple files from Angular to .net core Web Api
body: <p>My server uses .Net Core 2.1.402</p>
  
  <p>Here is my C# class:</p>
  
  <pre><code>public class SampleDetailsDto
  {
      public Guid Id{ get; set; }
      public string Text { get; set; }
      public IEnumerable&lt;string&gt; ImageUrls { get; set; }
      public IFormCollection Images { get; set; }
  }
  </code></pre>
  
  <p>Here is my C# Controller</p>
  
  <pre><code>[HttpPut]
  [Route("{id:guid}")]
  public async Task&lt;IActionResult&gt; UpdateAsync([FromRoute]Guid id, [FromForm] SampleDetailsDtodto)
  {
      Console.WriteLine(dto.Text); 
      Console.WriteLine(dto.Images.Length);
      return OK();
  }
  </code></pre>
  
  <p>I use nswag to generate the client service, but there is currently a bug (<a href="https://github.com/RSuter/NSwag/issues/1421#issuecomment-424480418" rel="nofollow noreferrer">https://github.com/RSuter/NSwag/issues/1421#issuecomment-424480418</a>) with upload multiple files, so I extended the update method to create mine, here is the code:</p>
  
  <pre><code> public update(id: string, dto: SampleDetailsDto | null | undefined): Observable&lt;SampleDetailsDto | null&gt; {
      let url_ = this._baseUrl + "/api/v1/Sample/{id}";
      if (id === undefined || id === null)
        throw new Error("The parameter 'id' must be defined.");
      url_ = url_.replace("{id}", encodeURIComponent("" + id));
      url_ = url_.replace(/[?&amp;]$/, "");
  
      let options_: any = {
        observe: "response",
        responseType: "blob",
        headers: new HttpHeaders({
          "Accept": "application/json"
        })
      };
      return _observableFrom(this.transformOptions(options_)).pipe(_observableMergeMap(transformedOptions_ =&gt; {
        return this._http.put&lt;SampleDetailsDto&gt;(url_,dto, transformedOptions_);
      })).pipe(_observableMergeMap((response_: any) =&gt; {
        return this.transformResult(url_, response_, (r) =&gt; this.processUpdate(&lt;any&gt;r));
      })).pipe(_observableCatch((response_: any) =&gt; {
        if (response_ instanceof HttpResponseBase) {
          try {
            return this.transformResult(url_, response_, (r) =&gt; this.processUpdate(&lt;any&gt;r));
          } catch (e) {
            return &lt;Observable&lt;SampleDetailsDto | null&gt;&gt;&lt;any&gt;_observableThrow(e);
          }
        } else
          return &lt;Observable&lt;SampleDetailsDto | null&gt;&gt;&lt;any&gt;_observableThrow(response_);
      }));
    }
  </code></pre>
  
  <p>I would like to upload multiple files and data at the same time, in this case all the images are linked to SampleDetailsDto. But we can imagine have this case kind of case too:</p>
  
  <pre><code>public class SampleDetailsDto
  {
      public Guid Id{ get; set; }
      public string Text { get; set; }
      public IEnumerable&lt;ChildSampleDetailsDto&gt; Children{ get; set; }
  }
  
  public class ChildSampleDetailsDto
  {
      public Guid Id{ get; set; }
      public string Text { get; set; }
      public IEnumerable&lt;string&gt; ImageUrls { get; set; }
      public IFormCollection Images { get; set; }
  }
  </code></pre>
  
  <p>Is it possible to send Data + multiple files to a .net Core Web Api?</p>
  
  <p>Thanks</p>