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:
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- else
- {
- app.UseExceptionHandler("/Error");
- }
- ....
- ....
- }
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.