microsoft / microsoft/aspire

When adding a WebAssembly project with Blazor server to an Aspire project, the port for the launched application changes on each launch

Open
#9,441 0 comments 1 reaction 0 assignees View on GitHub
area-app-model blazor-wasm
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

This is an issue with adding external auth providers like Google auth, which require the Authorized JavaScript origins and Authorized redirect URIs to be specified for every URL that might get launched.

```cs
builder.AddProject("blazorserver");
builder.AddProject("blazorserverclient");
```

Is there a way to force the launched application to always start with the same port? When I look at the details for the server project I see an endpoint named "https target port" with the correct port but attempting to set this with doesn't work. It needs dashes because it complains that the name of the endpoint cannot have spaces despite it appearing like spaces are what the default uses.

```cs

builder.AddProject("blazorserver");
.WithHttpsEndpoint(port: 56814, name: "https-target-port")
.WithHttpEndpoint(port: 58642, name: "http-target-port");
```

### Expected Behavior

To be able to keep a consistent port from launch to launch.

### Steps To Reproduce

Add a webassembly and blazor server project to an aspire project. Launch repeatedly and see the launched window port is always different.

### Exceptions (if any)

_No response_

### .NET Version info

.NET 9.0

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.