如何为ASP.NET Core网站指定WebSocket端口?它只使用默认端口,用于调试是59451.我想打开两个端口,但我无法弄清楚如何在ASP.NET Core中设置WebSocket端口。
ASP.NET Core
app.UseWebSockets();
app.Use(async (context, next) =>
{
if (context.Request.Path == "/upload")
{
// context.WebSockets.
if (context.WebSockets.IsWebSocketRequest)
{
// this uses default port 59451
WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync();
}
}
}
javascript:
uploadWebSocket = new WebSocket("ws://localhost:59451/upload");