When send a file that has a Vendor Specific Content-Type
to an application ASP.NET Core 1.0 your Content-Type is transformed into a different content type.
Question: How to keep the original Content-Type in upload/storage (Azure)/download. Should any changes be made to Startup.cs
orWeb.config
(done manually, but does it work)?
Content-Type Original: application/vnd.ms-pki.stl
Content-Type after send or autobind (I did not identify when the conversion is done): application/octet-stream
Submission: the form is sent via Ajax
$.ajax({
url: url,
data: new FormData($("#")[0]),
type: 'POST',
processData: false,
contentType: false,
beforeSend: function () {
// omitted
},
success: function (data) {
// omitted
},
error: function (data) {
// omitted
}
});
Target Action:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(PrintObjectCreateVM printObject)
{
if (!ModelState.IsValid)
{
return NotFound();
}
await PrintObjectService.Insert(printObject);
return Ok();
}
Action Model:
public class PrintObjectCreateVM
{
public IFormFile PrintObjectImage { get; set; }
public IFormFile PrintObjectPrintFile { get; set; }
}