Skip to content

Wrap AddDatabaseDeveloperPageExceptionFilter() in IsDevelopment() guard#52774

Open
Copilot wants to merge 2 commits intomainfrom
copilot/add-2nd-conditional-to-templates
Open

Wrap AddDatabaseDeveloperPageExceptionFilter() in IsDevelopment() guard#52774
Copilot wants to merge 2 commits intomainfrom
copilot/add-2nd-conditional-to-templates

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

AddDatabaseDeveloperPageExceptionFilter() is a development-only service that exposes sensitive database information. Three architecture doc code samples registered it unconditionally, meaning production apps following these examples would register a dev-only diagnostic service unnecessarily.

Fixes #23037

Changes

  • blazor-for-web-forms-developers/project-structure.md
  • blazor-for-web-forms-developers/security-authentication-authorization.md
  • modern-web-apps-azure/develop-asp-net-core-mvc-apps.md

All three samples updated from:

builder.Services.AddDbContext<ApplicationDbContext>(...);
builder.Services.AddDatabaseDeveloperPageExceptionFilter();  // unconditional

to:

builder.Services.AddDbContext<ApplicationDbContext>(...);

if (builder.Environment.IsDevelopment())
{
    builder.Services.AddDatabaseDeveloperPageExceptionFilter();
}

This matches the existing pattern already used in these same files for app.UseMigrationsEndPoint().

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • learn.microsoft.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


Internal previews

📄 File 🔗 Preview link
docs/architecture/blazor-for-web-forms-developers/project-structure.md docs/architecture/blazor-for-web-forms-developers/project-structure
docs/architecture/blazor-for-web-forms-developers/security-authentication-authorization.md docs/architecture/blazor-for-web-forms-developers/security-authentication-authorization
docs/architecture/modern-web-apps-azure/develop-asp-net-core-mvc-apps.md docs/architecture/modern-web-apps-azure/develop-asp-net-core-mvc-apps

…ter() calls

Agent-Logs-Url: https://github.com/dotnet/docs/sessions/dd9b2ea5-4aa5-48f9-8be3-6ac8e7d611a9

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copilot AI changed the title [WIP] Add 2nd conditional to standard templates for ConfigureServices Wrap AddDatabaseDeveloperPageExceptionFilter() in IsDevelopment() guard Mar 31, 2026
Copilot AI requested a review from BillWagner March 31, 2026 16:24
@BillWagner BillWagner marked this pull request as ready for review March 31, 2026 19:55
@BillWagner BillWagner requested review from a team and danroth27 as code owners March 31, 2026 19:55
Copilot AI review requested due to automatic review settings March 31, 2026 19:55
Copy link
Copy Markdown
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates architecture guide code samples to register AddDatabaseDeveloperPageExceptionFilter() only in development, preventing production apps from enabling a dev-only diagnostic service that can expose sensitive database details.

Changes:

  • Wrapped AddDatabaseDeveloperPageExceptionFilter() in if (builder.Environment.IsDevelopment()) { ... } in three documentation code samples.
  • Aligned the service-registration pattern with the existing app.UseMigrationsEndPoint() development-only guard shown in the same samples.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
docs/architecture/blazor-for-web-forms-developers/project-structure.md Updates the Program.cs sample to conditionally add the database developer exception filter in development only.
docs/architecture/blazor-for-web-forms-developers/security-authentication-authorization.md Updates the EF Core/Identity configuration snippet to guard the dev-only exception filter behind IsDevelopment().
docs/architecture/modern-web-apps-azure/develop-asp-net-core-mvc-apps.md Updates the Identity configuration sample to register the database developer exception filter only for development environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

need 2nd conditional and in standard templates

3 participants