404 Status code not returned
There are instances when an error in the ServiceAPI will return an HTTP status 200, rather than one of the 400 status codes. Unfortunately there are one or two cases where an internal exception falls outside of the standard error pipeline, this is something to be addressed in a future release.
A workaround
Any exception not handled will fall back to using a global error handler, at the moment this handler is not setting the status code, meaning it defaults to 200. You can fix this yourself. To do this:
- go to the ServiceAPI server
- edit the file \RazorPages\GlobalErrors.cshtml
- add the code 'this.Response.StatusCode = 404;' into the header (see example below)
Also...
Given that this file does the layout for unhandled errors you can make other modifications to it as well, if you want it to fit into your site design.
Written on November 21, 2016