I FOUND THE SOLUTION!
public async Task<IAactionResult> Export(ExportType fileType)
{
var result = await _someService.ExportAsync(fileType);
var fileResult = new FileContentResult(result.Content,contentType)
{
FileDownloadName = result.FileName,
};
return fileResult;
}
I have an ExportResult class:
public class ExportResult
{
public string FileName { get; set; } = null!;
public byte[] Content { get; set; } = null!;
}
And I have an Export method in a controller:
public async Task<ExportResult> Export(ExportType fileType)
{
var result = await _someService.ExportAsync(fileType);
return result;
}
The problem is the content-disposition response header didn't show up.
I tried to add to cors with these, but it doesn't work.
.WithExposedHeaders("content-disposition");
.WithExposedHeaders("Content-Disposition");