Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obsolete WebHostBuilder #20964

Open
Tratcher opened this issue Apr 17, 2020 · 25 comments
Open

Obsolete WebHostBuilder #20964

Tratcher opened this issue Apr 17, 2020 · 25 comments
Labels
affected-most This issue impacts most of the customers area-hosting Includes Hosting Docs This issue tracks updating documentation enhancement This issue represents an ask for new feature or an enhancement to an existing one severity-minor This label is used by an internal tool
Milestone

Comments

@Tratcher
Copy link
Member

WebHostBuilder was replaced by HostBuilder in 3.0. In 5.0 we should consider obsoleting the old one.

@analogrelay
Copy link
Contributor

To clarify even more, the idea here is to obsolete the types and public APIs on:

The obsolete message should include an aka.ms link that points to https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-3.1#settings-for-web-apps

@analogrelay analogrelay added this to the Next sprint planning milestone Apr 17, 2020
@analogrelay analogrelay added the Docs This issue tracks updating documentation label Apr 17, 2020
@davidfowl
Copy link
Member

We shouldn’t do this until we resolve the remaining gaps that people complain about:

  • Passing extra state to the startup class (for e.g)

@Tratcher
Copy link
Member Author

  • Passing extra state to the startup class

Related issue: #19809

@davidfowl
Copy link
Member

Also the IStartup replacement.

@BrennanConroy
Copy link
Member

BrennanConroy commented May 8, 2020

Lets start cleaning up areas before obsoleting this starting in preview6.

@BrennanConroy
Copy link
Member

BrennanConroy commented Jul 7, 2020

Example changes #23626

Make sure to dispose the IHost.

Common changes:

Before:

var host = new WebHostBuilder()
    .Configure(app =>
    {
        //...
    }).Build();

After:

using var host = new HostBuilder()
    .ConfigureWebHost(webHostBuilder =>
    {
        webHostBuilder
        .Configure(app =>
        {
            //...
        }
    }).Build();

TestServer:
Before:

var builder = new WebHostBuilder();
var server = new TestServer(builder);

After:

using var host = new HostBuilder()
    // ...
    .UseTestServer()
    .Build();
var server = host.GetTestServer();
await host.StartAsync(); // new TestServer(builder); used to run Start, but we don't use that anymore

@BrennanConroy
Copy link
Member

BrennanConroy commented Jul 7, 2020

@mkArtakMSFT Can you find some folks to handle MVC?
@HaoK Can you take care of Identity/Security?

Read previous comment for some helpers.

@HaoK
Copy link
Member

HaoK commented Jul 7, 2020

Yup I can do identity/security

@davidfowl
Copy link
Member

Just to be clear, we're not obsoleting anything in 5.0 😄. We haven't scheduled the linked items though I am supportive of updating the other projects.

@HaoK
Copy link
Member

HaoK commented Jul 8, 2020

How bad is it if the host doesn't get disposed? There's a bunch of tests that rely on a helper method that creates the server, which if the helper has a using var host, the host gets disposed and the test code fails due to object disposed.

i.e.

   Task<TestServer> CreateServer() { 
      using var host = ... .Build(); 
      await host.StartAsync();
      return host.GetTestServer();

@BrennanConroy
Copy link
Member

You'll get hangs because by default the console lifetime service is hooked up which waits for ctrl-c (or dispose) before closing.

I changed a bunch of helpers in middleware to return IHost instead of TestServer.

@HaoK
Copy link
Member

HaoK commented Jul 8, 2020

Hangs? Everything seems to work fine if I just drop the using

@HaoK
Copy link
Member

HaoK commented Jul 8, 2020

meaning the tests complete just fine without the using

@BrennanConroy
Copy link
Member

Yeah, I'm not sure how VS handles that, but when running from command line you should see hangs.

@HaoK
Copy link
Member

HaoK commented Jul 8, 2020

I just tried via dotnet test and it 'worked'. Does that mean its ok?

@Tratcher
Copy link
Member Author

Tratcher commented Jul 8, 2020

@BrennanConroy the other thing we should consider is having UseTestServer register its own lifetime to replace ConsoleLifetime. The implementation should be a no-op.

@BrennanConroy BrennanConroy added this to the Next sprint planning milestone Nov 2, 2020
@ghost
Copy link

ghost commented Nov 2, 2020

Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@ghost
Copy link

ghost commented Mar 30, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@ghost
Copy link

ghost commented Sep 13, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@amcasey amcasey added area-hosting Includes Hosting and removed feature-hosting labels Jun 1, 2023
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
@adityamandaleeka adityamandaleeka added net8_docathon This issue is part of the documentation push in Fall 2023. and removed area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions net8_docathon This issue is part of the documentation push in Fall 2023. labels Aug 25, 2023
@halter73 halter73 modified the milestones: .NET 9 Planning, Backlog Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-most This issue impacts most of the customers area-hosting Includes Hosting Docs This issue tracks updating documentation enhancement This issue represents an ask for new feature or an enhancement to an existing one severity-minor This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests