I just moved my project to ASP.Net Core from ASP.Net 4.5. I've a REST API get that used to return a blob but now is returning JSON instead.
This is the old code:
[HttpGet]
[ResponseType(typeof(HttpResponseMessage))]
[Route("Download/{documentId}")]
public async Task<HttpResponseMessage> DownloadDocument(string documentId)
{
try
{
var result = await TheDocumentService.DownloadDocument(documentId);
return result;
}
catch (Exception ex)
{
return new HttpResponseMessage
{
StatusCode = HttpStatusCode.InternalServerError,
Content = new StringContent(ex.Message)
};
}
}
The code in ASP.net Core is the same except for [ResponseType(typeof(HttpResponseMessage))]
not working in ASP.Net Core, also the return result is also the same in both solutions.
But when looking at the response from the server in the client they differ.
So the only thing that differs them both from each other are the [ResponseType(typeof(HttpResponseMessage))]
. Is there something equivalent in asp.net core?
[HttpGet] [Route("Download/{documentId}")]