location /myappHub {
proxy_pass http://localhost:5000/myappHub;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
请将“myapp”替换成您自己的应用程序名称。
services.AddSignalR();
app.UseEndpoints(endpoints =>
{
endpoints.MapHub("/myappHub"); //请替换成您自己的应用程序名称
endpoints.MapFallbackToFile("index.html");
});
@using Microsoft.AspNetCore.SignalR.Client
@inject NavigationManager NavigationManager
...
var connection = new HubConnectionBuilder()
.WithUrl(NavigationManager.ToAbsoluteUri("/myappHub"))
.Build();