public async Task <FileStreamResult> UploadSalesOrder(IFormFile file) { if (file != null || file.Length > 0) { using (var ms = new MemoryStream()) { file.CopyTo(ms); ms.Seek(0, SeekOrigin.Begin); var response = await _applicationServices.UploadSingleSalesOrderAsync(ms); if (response != null) { if (response.Item1 == 200 || response.Item1 == 201) { return new FileStreamResult(response.Item2, "text/xml") { FileDownloadName = "response.xml" } } ; else { return new FileStreamResult(response.Item2, "text/plain") { FileDownloadName = "errorResponse.txt" } }; } } } var noResponseFile = GetNoResponseFile(); return(new FileStreamResult(noResponseFile, "text/plain") { FileDownloadName = "noresponse.txt" }); }