-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Call WebApplication.CreateBuilder(args) only once #34492
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
aspnetcore/fundamentals/configuration/index.md:63
- [nitpick] The sentence could be rephrased for clarity: 'Although this article mentions
WebApplication.CreateBuilder(args)multiple times, application code should call this method only once.'
> While this article mentions `WebApplication.CreateBuilder(args)` many times, application code should call this method only once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overreaction to one customer and too much bling. I'd change it to:
Do a search on WebApplication.CreateBuilder(args), all the code samples show it's only called once. This is not a recurrent problem.
NOTE:: WebApplication.CreateBuilder(args) should only be called once.
The 2nd time you call it
var builder = WebApplication.CreateBuilder(
you get a compiler error.
I'm not sure I'd even need a warn. We can't overreact to every error a customer makes and spam the topic with warnings.
Co-authored-by: Rick Anderson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
| 1. [appsettings.json](#appsettingsjson) using the [JSON configuration provider](#jcp). | ||
| 1. A fallback to the host configuration described in the [next section](#host). | ||
|
|
||
| Note: `WebApplication.CreateBuilder(args)` should only be called once. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Note: `WebApplication.CreateBuilder(args)` should only be called once. |
Many of our docs use the same API many times, for example app.UseCors `https://learn.microsoft.com/en-us/aspnet/core/security/cors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link we originally had here tells why you don't want to call this API multiple times but people tend to think it can or needs to be. Perhaps it would be good to put the link back in?
https://techcommunity.microsoft.com/blog/iis-support-blog/asp-net-core-503-server-has-been-shutdown/3830338
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
Co-authored-by: Stephen Halter <[email protected]>
Fixes #34216
Internal previews