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

Call WebApplication.CreateBuilder(args) only once #34492

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tdykstra
Copy link
Contributor

@tdykstra tdykstra commented Jan 14, 2025

Fixes #34216


Internal previews

📄 File 🔗 Preview link
aspnetcore/fundamentals/configuration/index.md Configuration in ASP.NET Core

@tdykstra tdykstra requested a review from Copilot January 14, 2025 00:38

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.
@tdykstra tdykstra marked this pull request as ready for review January 14, 2025 00:38
Copy link
Contributor

@Rick-Anderson Rick-Anderson left a 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.

Comment on lines +62 to +63
> [!IMPORTANT]
> While this article mentions `WebApplication.CreateBuilder(args)` many times, application code should call this method only once. For more information, see [this IIS Support blog post](https://techcommunity.microsoft.com/blog/iis-support-blog/asp-net-core-503-server-has-been-shutdown/3830338).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
> [!IMPORTANT]
> While this article mentions `WebApplication.CreateBuilder(args)` many times, application code should call this method only once. For more information, see [this IIS Support blog post](https://techcommunity.microsoft.com/blog/iis-support-blog/asp-net-core-503-server-has-been-shutdown/3830338).
Note: `WebApplication.CreateBuilder(args)` should only be called once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

suggest warning on doc page "Configuration in ASP.NET Core"
2 participants