I've been following the answers in the post linked below in order to return a file using a dotnet api to return a file.
How to return a file using Web API?
In the swagger I am able to make the call however, all I am getting back is a json object instead of the browser opening the file when I navigate directly to the URL.(https://localhost:5001/api/SiteLink/gandrfiles/1).
Any ideas why the browser won't open the file? Thanks!
Json returned:
{
"version": {
"major": 1,
"minor": 1,
"build": -1,
"revision": -1,
"majorRevision": -1,
"minorRevision": -1
},
"content": {
"headers": [
{
"Key": "Content-Disposition",
"Value": [
"attachment; filename=Contact_Us_Page.pdf"
]
},
{
"Key": "Content-Type",
"Value": [
"application/octet-stream"
]
}
]
},
"statusCode": 200,
"reasonPhrase": "OK",
"headers": [],
"trailingHeaders": [],
"requestMessage": null,
"isSuccessStatusCode": true
}
I ended up following the answer on the original post provided by Amir Shirazi and it worked. I don't know why the answer by Regfor didn't do the trick but it didn't work in the project.