Skip to content

WebHost doesn't detect ASPNETCORE_HTTP_PORTS #51125

@tmds

Description

@tmds

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The .NET images for .NET 8 changed from using ASPNETCORE_URLS to using ASPNETCORE_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

using Microsoft.AspNetCore ;

public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>();
}

class Startup
{
    public void Configure()
    { }
}
$ ASPNETCORE_HTTP_PORTS=8080 dotnet run --no-launch-profile
Hosting environment: Production
Content root path: /tmp/web2
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions