ASP.NET Core 2 - Missing content-type boundary

假装没事ソ 提交于 2020-12-25 08:39:22

问题


I'm trying to upload a file from a Angular client to my ASP.NET Core 2 WebAPI service. When I call the service, I get back an Internal Server Error. That's the error I'm getting:

The component I'm using client-side is this one: ngx-uploader

In my request options, i set them as you can see here:

  const event: UploadInput = {
  type: 'uploadAll',
  url: this.printService.apiFilesBaseUrl + '/Upload',
  method: 'POST',
  file: this.files[0],
  headers: {
    'Content-Type': 'multipart/form-data',
    'Accept': '*/*',
    'Authorization': 'Bearer ' + this.authService.getToken()
  }
};

While, server-side my controller action signature is this one:

    [HttpPost]
    [Route("Upload")]
    [Authorize]
    public Guid Post(IFormFile file)

Breakpoints in this controller action never get hit.

Can someone please share ideas about what's happening here?

Here, as requested, i will post my request header and payload:

Thanks in advance.


回答1:


Check upload request in developer tools network tab, it should have correct format (matching 'Content-Type': 'multipart/form-data'), also you could try removing this header.



来源:https://stackoverflow.com/questions/51943586/asp-net-core-2-missing-content-type-boundary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!