Purpose Of UseDeveloperExceptionPage() In .Net Core.

The major purpose of  UseDeveloperExceptionPage() is to help the user to inspect exception details during the development phase.
 
Namespace for the method - Microsoft.AspNetCore.Builder
 
Purpose of function 
  • To capture Synchronous and Asynchronous SystemException instance from the pipeline & generate HTML error response. It returns a reference to the application after the operation is completed.
  • We use the UseDeveloperException() extension method to render the exception during the development mode
  • This method adds middleware into the request pipeline which displays developer-friendly exception detail page. This helps developers in tracing errors that occur during the development phase
To use this method open the Startup.cs file, locate the Configure() method and make the below changes to it:
  1. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)  
  2. {  
  3.             if (env.IsDevelopment())  
  4.             {  
  5.                     app.UseDeveloperExceptionPage();  
  6.                }  
  7.             else  
  8.                {  
  9.                     app.UseExceptionHandler("/Error");  
  10.                }  
  11.               ....  
  12.               ....  
  13. }  
This is the way developers can add exception-related functionality to the code and can inspect their exceptions during the development phase.
 
So, this is going be helpful for developers when it comes to writing  error-free code.