Please provide a way to disable the DeveloperExceptionPage during development.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
If I am using the `WebApplication.Create` method, the DeveloperExceptionPage is automatically enabled in the development environment.
Please provide a way to disable this.
### Describe the solution you'd like
There are multiple ways to do this. Any method is fine.
For example:
```cs
services.DisableDeveloperExceptionPage();
```
Or
```cs
WebApplication.CreateBuilder(
new WebApplicationOptions {
Args = args,
DisableDeveloperExceptionPage = true
});
```
### Additional context
Similar requests have been submitted and rejected in the past. (#43870, #47293)
I want to observe the behavior when an exception occurs in the production environment during development.
But when DeveloperExceptionPage is enabled, a user-friendly display is shown, and I don't get the actual error that would be returned in the production environment (e.g. `application/problem+json`).
Solutions such as setting the `DOTNET_ENVIRONMENT` environment variable to `Production` or using `WebApplication.CreateSlimBuilder` method are difficult to use.
If the `DOTNET_ENVIRONMENT` environment variable is changed, the `appsettings.*.json` file that is loaded will change, which may result in settings that are unsuitable for the development environment, for example, preventing database connections.
And if I use the `WebApplication.CreateSlimBuilder` method instead of the `WebApplication.Create` method, there are some services that will be disabled, so I have to investigate and supplement them.
I only want to disable the DeveloperExceptionPage, and I don't want to disable any other services.
I don't want to complete and deploy this application with DeveloperExceptionPage disabled. I only want to temporarily disable it in local environment with minimal changes.
The method mentioned above is too costly for this purpose.
Contributor guide
Research direction
Start by tracing how WebApplication.Create and WebApplication.CreateBuilder enable the DeveloperExceptionPage in development, then review the prior requests #43870 and #47293. Determine whether a narrowly scoped opt-out can preserve other development services and appsettings behavior; done means production-style exception responses can be observed locally without changing the environment or using CreateSlimBuilder.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100