Monday, July 20, 2020

ASP.NET Core trick: breakpoint for 404 errors

I had an 404 error for a test web app that used a NGINX reverse-proxy config file, which was pretty hard to track it down. Most of the routes worked fine, except pages under an /admin folder, all throwing 404 error, page not found.

The easiest thing to track it down is a break-point somewhere, but where exactly, for a page that's not found? So, I added temporarily a middleware in Startup.cs, by the book:

app.Use(async (context, next) =>
// Do work that doesn't write to the Response.
await next.Invoke();
// Do logging or other work that doesn't write to the Response.

Then just add the break-point on highlighted line and inspect the Request object.

In my case I only needed a backslash in proxy_pass parameter of NGINX's config file.