From the course: Learning ASP.NET Core MVC

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Error handling and diagnostics

Error handling and diagnostics

From the course: Learning ASP.NET Core MVC

Start my 1-month free trial

Error handling and diagnostics

- [Narrator] Now that I've shown you how to use ASP.NET Core's middleware to execute server side logic and serve static content, I'm going to get a little paranoid for a bit and show you how to register error handling logic to try and help salvage your user's experience when something in your application inevitably goes wrong. To demonstrate an error, I'll just add a bit of code to the configure method in the startup class that throws an exception when the URL contains the word: invalid. Then I'll run the site and navigate to a URL like /invalid. Here I'm greeted by an incredibly helpful error message containing all kinds of useful information to help me figure out what went wrong with my application. At the top, it shows me the error message and then lower down I can click on various sections of the stack trace and, if it's my code, I can actually see that code right there in my browser. In addition to the stack trace information, the page also has several other tabs that allow me to…

Contents