-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
WebHost doesn't detect ASPNETCORE_HTTP_PORTS #51125
Comments
Correct, the legacy WebHost APIs do not support new features like ASPNETCORE_HTTP_PORTS. |
Probably the old API is still being used since it's still functional and not deprecated. Since container images are now using the new envvar, do you think it's worth calling this out as part of the breaking changes? Perhaps include this in https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/aspnet-port? cc @mthalman |
Why not? |
@Tratcher what can we do for .NET 8 GA? |
Because it's twice as much work to implement new features in both places and in most cases, WebHost doesn't need the new features. We'd only consider this if it was going to cause a significant interop issue?
Not much, .NET 8 is locking down and only taking servicing level fixes at this point. @adityamandaleeka? |
Users reading https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/aspnet-port will assume their ASP.NET app will change to port The The |
Sorry, I'm getting a little mixed up because I think there's some implicit context in the problem discussion that I'm missing. Do I understand correctly that the dotnet container images were updated for 8.0 to start configuring aspnetcore via What would happen if the container image(s) set both environment variables? I'm assuming the newer one would win in any code path that supports both? |
The newer envar was introduced to be more user-friendly. When both are set, the new envvar gets ignored for backwards compatibility.
Yes. They don't know about the envvar that is set in the 8.0 container images. It causes them to bind to port 5000.
There is no breaking change doc about the WebHost port yet. There is one about the port changing from 80 to 8080: https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/aspnet-port. |
What's the back compat issue? Consumers who were setting Edit: To be explicit, you're correct, it's just not immediately obvious to me why it was done that way. |
The reason is backwards compatibility. If user was setting |
If I understand correctly, the scenario of concern is when the user has specified If so, how did the container tooling formerly handle the case where the user had specified And the reason the container tooling prefers not to continue using |
The scenario of concern is when a user has not specified the Before .NET 8, ASPNET Core binds to port 80. With the .NET 8 images, applications that use the newer Applications that use the older |
@tmds Thanks for the explanation! I agree with your assessment that this will be disruptive to some users and needs to be documented. My questions were more aimed at improving my understanding of what could have been done to avoid getting into this state and what we could do to get out of it in the future. |
I can explain the behavior. It's not quite as described. It's neither due to compat or "winning". It's much simpler.
|
@Tratcher Which hosts support |
Do: 'Modern' hosts, everything since 3.0: aspnetcore/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs Lines 20 to 21 in 2b7e994
aspnetcore/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs Line 17 in d025c79
Do not: 'Legacy' hosts: aspnetcore/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Program.cs Line 21 in 1be20f4
So if an application was created using the 2.1 templates and then updated to later versions without updating the host code, they could run into this. |
What I said about versions is confusing. The hosting APIs introduced in 3.0 and later have been updated in 8.0 to support |
@tmds is the scenario that came to your attention a legacy app or was there a compelling reason to write a new app in an old style? |
Apps using the old APIs which haven't been updated. These APIs aren't marked obsolete and are still functional. Some users aren't inclined update their apps to use newer APIs until the old ones stop working. |
I think that updating the breaking change docs to cover this case is warranted. It probably just needs a sentence of two. https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/aspnet-port |
...rather than port 8080, like newer hosts. Fixes dotnet/aspnetcore#51125
Is there an existing issue for this?
Describe the bug
The .NET images for .NET 8 changed from using
ASPNETCORE_URLS
to usingASPNETCORE_HTTP_PORTS
.Older applications using the
WebHost
API don't seem to pick up the new environment variable.Expected Behavior
Applications using the
WebHost
API should use the new environment variables.Or this should be documented as a breaking change.
Steps To Reproduce
As shown in the output, the application binds to port 5000 instead of port 8080 as set by the envvar.
Exceptions (if any)
No response
.NET Version
8.0.100-rc.1.23455.1
Anything else?
No response
The text was updated successfully, but these errors were encountered: