Skip to content

Add UseSentry overloads on WebApplicationBuilder #5719

Closed

Description

@ric-oliv

Problem

On a minimal-hosting app, Sentry is added with builder.WebHost.UseSentry(...), which returns the IWebHostBuilder. In the template's fluent style, the following .Build() then resolves to IWebHostBuilder.Build():

var app = WebApplication.CreateBuilder(args)
    .WebHost.UseSentry(o => o.Dsn = "...")
    .Build();                      // an IWebHost, not a WebApplication
app.MapGet("/", () => "Hello");

That gives warning ASPDEPR008 (IWebHost is obsolete in .NET 10) and CS1929 on MapGet. If it compiled, ConfigureWebHostBuilder.Build() would throw NotSupportedException. Found with a fresh dotnet new web app while checking the onboarding snippets (#5700).

Proposal

Add UseSentry overloads on WebApplicationBuilder in Sentry.AspNetCore, mirroring the IWebHostBuilder set and returning the application builder:

public static WebApplicationBuilder UseSentry(this WebApplicationBuilder builder);
public static WebApplicationBuilder UseSentry(this WebApplicationBuilder builder, string dsn);
public static WebApplicationBuilder UseSentry(this WebApplicationBuilder builder, Action<SentryAspNetCoreOptions>? configureOptions);
public static WebApplicationBuilder UseSentry(this WebApplicationBuilder builder, Action<ISentryBuilder>? configureSentry);

Each one calls the matching builder.WebHost.UseSentry(...) overload and returns builder, so the behavior is the same as today's call: on WebApplicationBuilder, builder.WebHost applies those registrations immediately. The WebHostBuilderContext overloads aren't needed, since configuration and environment are in scope where UseSentry is called.

The change is additive, so it targets main (6.x) and reaches v7 with the next merge of main into version7. The samples switch to builder.UseSentry(...); docs and onboarding snippets follow in #5700.

Split out of #5572. That issue adds a generic-host UseSentry on IHostApplicationBuilder in v7, and WebApplicationBuilder implements that interface, so in apps that reference both packages this overload is what keeps builder.UseSentry() on the ASP.NET Core integration.

Activity

  1. self-assigned this
    on Oct 13, 2026
  2. linear-code commented on Oct 13, 2026

    @linear-code
  3. added a commit that references this issue on Oct 19, 2026
    1551b2a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions