Currently, in my asp.net core api controller, I have the following code snippet:
return new FileStreamResult(excel, "application/ms-excel")
{
FileDownloadName = filename
};
Afterwards, I make an ajax request to fetch this file:
var response = axios.get(
`/endpoint`, {
responseType: 'blob'
});
Once the response is received, I utilize a library named download. This library requires 3 parameters, one of which is called "filename". Is there a way for me to extract and use the filename provided by the server?
download(response.data,"test.xlsx", content);
Regarding Cors:
services.AddCors(options => options.AddPolicy("Cors",
builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
}));