Skip to content

Can't set a static port/endpoint of auto reload script when running dotnet watch run. #33823

@aaronamm

Description

@aaronamm

Hello everyone

I have setup a Docker compose file with a custom image to launch ASP.NET Core MVC app with dotnet watch run.
However, I can't make a browser to auto reload when some code has been changed.

This is because a container does not publish a port number that aspnetcore-browser-refresh.js use to create a WebSocket connection.

I found that we have ASPNETCORE_AUTO_RELOAD_WS_ENDPOINT defined in
https://github.com/dotnet/sdk/blob/release/5.0.2xx/src/BuiltInTools/BrowserRefresh/BrowserScriptMiddleware.cs#L23 but setting a value of ASPNETCORE_AUTO_RELOAD_WS_ENDPOINT environment variable does not change a WebSocket endpoint.
It always get a random port number whenever we run dotnet watch run and cause me to not be able to configure a published port number in a Docker compose file.

Here is a screenshot of the WebSocket issue.

image

How to reproduce an issue:

Please follow the instruction in this README https://github.com/codesanook/Codesanook.EFNote#how-to-run-the-project-locally

My development environment

Please could you help me figure it out how to make a stick port number of WebSocket in a browser reload script?
Thanks.

Other useful information

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-hot-reloadThis issue is related to the Hot Reload feaature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions