The easiest way to skip DeveloperExceptionPageMiddleware
is not using the Development
environment.
You can modify the Properties/launchSettings.json
file, change ASPNETCORE_ENVIRONMENT
to anything but Development
.
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:43562",
"sslPort": 44332
}
},
"profiles": {
"api1": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7109;http://localhost:5111",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "MyDevelopment"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "MyDevelopment"
}
}
}
}
In your app, change all builder.Environment.IsDevelopment()
to builder.Environment.IsEnvironment("MyDevelopment")
.
UseExceptionHandler
never triggers, and the exception doesn't bubble up to any other middleware as it's caught inDeveloperExceptionPageMiddleware
and not passed further. β Ulrika