Skip to content

Fixer/Analyzer: Suggest rewriting builder.Host.ConfigureServices to builder.Services #35817

Closed
@davidfowl

Description

@davidfowl

We should rewrite:

var builder = WebApplication.CreateBuilder(args);

builder.Host.ConfigureServices(services =>
{
    services.AddAntiforgery();
});

// OR

builder.WebHost.ConfigureServices(services =>
{
    services.AddAntiforgery();
});

To

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddAntiforgery();

Metadata

Metadata

Assignees

Labels

Priority:2Work that is important, but not critical for the releaseanalyzerIndicates an issue which is related to analyzer experiencearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-hostingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions