[WebToolsE2E] After creating a Blazor Web App project with the ".dev.localhost TLD" selected, I added some code and ran it, but an exception occurred: System.Net.Http.HttpRequestException: 'No such host is known.'
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
**REGRESSION INFO**: There is no "Use the .dev.localhost TLD in the application URL" option on 17.14.17
**INSTALL STEP**
1. Clean machine: Win11 x64 23H2 ENU
2. Install VS 18.0.0 Insiders 3 from https://aka.ms/vs/18/insiders/vs_Enterprise.exe
- Web workload
- Check 8.0/9.0 runtime
- Includes SDK 10.0 RC2
**REPRO STEPS**
1. File > New > Project > Blazor Web App > .NET 10.0 > WebAssembly ~ Global > Check "Use the .dev.localhost TLD in the application URL" > create.
2. Right click project BlazorSignalRApp.Client > select Manage NuGet Packages > install package 'Microsoft.AspNetCore.SignalR.Client'
3. Create a folder called 'Hubs' below BlazorSignalRApp
4. Right-click the Hubs folder to add a class called 'ChatHub.cs' and paste the following code
```
using Microsoft.AspNetCore.SignalR;
namespace BlazorSignalRApp.Hubs
{
public class ChatHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
}
```
5. In the BlazorSignalRApp project, open the Program.cs file and add the following code
```
builder.Services.AddSignalR();
builder.Services.AddResponseCompression(opts =>
{
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "application/octet-stream" });
});
...
app.UseResponseCompression();
...
app.MapHub("/chathub");
```
6. In the BlazorSignalRApp.Client project, open the Pages/Home.razor file, replace with the following code
```
@page "/"
@using Microsoft.AspNetCore.SignalR.Client
@inject NavigationManager NavigationManager
@implements IDisposable
User:
Message:
Send
- @message
@foreach (var message in messages)
{
}
@code {
#nullable disable warnings
private HubConnection hubConnection;
private List messages = new List();
private string userInput;
private string messageInput;
protected override async Task OnInitializedAsync()
{
hubConnection = new HubConnectionBuilder()
.WithUrl(NavigationManager.ToAbsoluteUri("/chathub"))
.Build();
hubConnection.On("ReceiveMessage", (user, message) =>
{
var encodedMsg = $"{user}: {message}";
messages.Add(encodedMsg);
StateHasChanged();
});
await hubConnection.StartAsync();
}
Task Send() =>
hubConnection.SendAsync("SendMessage", userInput, messageInput);
public bool IsConnected =>
hubConnection.State == HubConnectionState.Connected;
public void Dispose()
{
_ = hubConnection.DisposeAsync();
}
}
```
7. Build and run
**NOTE**: Change step 7 to do 'dotnet run' using the CLI, this issue will also be reproduced.
**ACTUAL**:
The project cannot be run.
System.Net.Http.HttpRequestException: 'No such host is known. (blazorsignalrapp.dev.localhost:7211)'
**EXPECTED**
The project can run successfully
Contributor guide
Assessment
This issue has not been assessed yet.