niico
niico

Reputation: 12779

Invalid route in ASP.net MVC Core 2 app shows blank page

I have a new empty asp.net MVC Core 2 web app. When going to a non-existant route rather than coming with an error page it just shows a blank page.

The site is setup with IIS. I'm in Development environment. I've tried commenting app.UserExceptionHandler("/Home/Error"); and app.UseDeveloperExceptionPage(); - I've tried them individually in my environment. None of it makes any difference, just blank pages returned.

Why aren't errors being returned when I enter an invalid route & how can I see them?

I also ran in debugging on the /Home/Error ActionMethod to see if it was being hit - it never was. Thanks.

Upvotes: 0

Views: 1413

Answers (1)

mvermef
mvermef

Reputation: 3924

short answer: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-2.0

long answer:

the first line won't get hit on the debugger. there is another configuration you can for error codes specifically but needs a little more wiring up.

app.UseStatusCodePagesWithRedirects("/error/{0}");

the target will be a 404.cshtml for a 404 not found. 401 etc. usually loaded from the shared folder, for example.

in your situation does error.cshtml exist in the home folder for the homecontroller? was the intent to have it for a SPA type app?

Upvotes: 1

Related Questions