Developer Exception Page – Session 13

Developer Exception Page Feature Image

In this session of ASP.NET Core Tutorial series, we are going to describe Developer Exception Page in detail. This page contains many useful information about unhandled error that occur in our App which could lead developer to solve their App bugs.

What is Developer Exception Page?

Developer Exception Page is a useful tool that is provided by ASP.NET Core to handle exceptions with technical information. UseDeveloperExceptionPage middleware, serves this page and can be modified with DeveloperExceptionPageOptions. Also, due to improving security and make UI more user friendly, this exception page should be used just in Development environment.

UseDeveloperExceptionPage Middlware

UseDeveloperExceptionPage middleware, serves Developer Exception Page. This middleware is added automatically to most of Web App which is created by ASP.NET Core Web App template. Also, The middleware should be added in top level of our Web App HTTP Request/Response pipeline. If you are not familiar with ASP.NET Core pipeline, you can see detail of this topic in session 7 of this tutorial series. Moreover, due to security reasons and being User Friendly Web App, it is highly recommended using this exception page just in Development stage. Because, as mentioned above the developer exception page contains technical information about our web app. Thus, this type of information is not understandable for end-user and can be used by malicious user for hacking purpose. Below piece of code shows you the way that you can add this middleware to your web app to be served just in Development environment.

Just bear in mind, during development, set ASPNETCORE_ENVIRONMENT variable to “Development” to receive Developer Exception Page while an error occur in your web-app. Otherwise, you will receive a Generic Exception Page which does not contain information about occurred error.

Developer Exception Page
Developer Exception Page
Generic Exception Page

Customize UseDeveloperExceptionPage Middleware

Same as most of the middleware, you can customize UseDeveloperExceptionPage middleware with its Options object. Thus, you can create an object of DeveloperExceptionPageOptions and do your customization with the object, then pass the object to the middleware. Also, you can create the Options object within middleware braces. Below code shows you both methods of customization.

through this customization, you can set number of code lines before and after the code line which throw exception. The above code, set this option to 10 code line before and after the code line that throw exception.

If you need more details, watch this session video. Also, for being updated about our coming sessions, follow us on Instagram, Facebook, Telegram or YouTube and you can have access to list of all sessions HERE.

You can download this Session Slides form HERE

0.00 avg. rating (0% score) - 0 votes


0 0 votes
Article Rating

Inline Feedbacks
View all comments