I am trying to get my 404s to work correctly, but cannot figure out how to do it right.
Initially, I installed the following in my Configure method:
app.UseMvc(routes =>
{
});
app.Use((context, next) =>
{
context.Response.StatusCode = 404;
return next();
});
app.UseStatusCodePagesWithRedirects("/error/{0}");
Which redirected to the page where I showed the error. However, there were status codes 302 > 200. I set the action /error/{code}to return the corresponding status code, so now I have 302 > 404one that (due to 302 redirection) makes it look like the page /error/404does not exist (which it does).
What I want to do is return the error page without redirecting, so trying to request /doesntexistwill return 404 and display the error page.
, , app.UseStatusCodePagesWithReExecute("/error/{0}");, 404 URL-, ,