Open ozonni opened 4 years ago
Oh interesting. I'll have to check this out as it should work. I'm currently prepping some changes for 3.1 which should be released in the next few days.
@JosephWoodward found it, i didn't configure this
x.ContentType = "application/json";
x.ResponseBody(s => JsonConvert.SerializeObject(new
{
Message = "An error occurred whilst processing your request"
}));
After adding this part, i'm getting HTTP 404.
I'm not sure if this should be required, since i just wanted to return HTTP 404 without any JSON response body
@ozonni Thanks for the update. What did your code look like before you added the above? Unless I'm wrong, it looks the same as the original sample you added when raising the issue?
@JosephWoodward right :) mb i copied wrong code. Sorry for that
Ah okay. None the less, you've highlighted that the following should really return a 404:
builder.UseGlobalExceptionHandler(x =>
{
x.Map<EntityNotFoundException>().ToStatusCode(HttpStatusCode.NotFound);
});
@JosephWoodward Is the release with pending changes for .NET Core 3.1 to be released soon?
@andregizero Yes, it's almost ready.
Any status on the changes for 3.1? Or if the current master can be pushed to nuget? There are some updates for loggers that would be awesome to integrate with.
Having this configuration and throwing
EntityNotFoundException
, i'm getting HTTP 500