Question: Cannot connect to WebSocket controller in .Net Core Blazor WASM application

I am trying to get a WebSocket connection going in my WASM application.
I have followed the MSDN tutorial and enabled WebSockets in my Program.cs:
app.UseWebSockets();

After that, I added a new controller like this:
[AllowAnonymous]
[ApiController]
[Route("[controller]")]
internal class ShellyPlusDataController : ControllerBase
{
    [HttpGet]
    [Route("[controller]/OnDataReceived")]
    public async Task OnDataReceived()
    {
        if (HttpContext.WebSockets.IsWebSocketRequest)
        {
            using var webSocket = await HttpContext.WebSockets.AcceptWebSocketAsync();

            var buffer = new byte[1024 * 4];
            WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);

            while (!result.CloseStatus.HasValue)
            {
                string raw = Encoding.UTF8.GetString(buffer, 0, result.Count);
                result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
            }

            await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
        }
        else
        {
            HttpContext.Response.StatusCode = StatusCodes.Status400BadRequest;
        }
    }
}

Opening a connection to 'wss://localhost:7220/ShellyPlusData/OnDataReceived' with PostMan doesn't work. The error displayed is: Error: Unexpected server response: 200
I have placed a breakpoint at the start of OnDataReceived(); it is never hit.
I have also tried changing the URL to ws:// or omitting the method name, but no success.
The Microsoft tutorial also suggests this in Program.cs:
app.Use(async (context, next) =>
{
    if (context.Request.Path == "/ws")
    {
        if (context.WebSockets.IsWebSocketRequest)
        {
            using var webSocket = await context.WebSockets.AcceptWebSocketAsync();
            await Echo(webSocket);
        }
        else
        {
            context.Response.StatusCode = StatusCodes.Status400BadRequest;
        }
    }
    else
    {
        await next(context);
    }
});

Doesn't work either.
Any suggestions?


Answer:
So I had to figure it out on my own. There were 2 things that needed to be fixed:

Local WebSocket connection doesn't work. I don't know what needs to be configured to enable WebSockets in local debug mode, but when I deploy the application to a remote IIS server, I can establish a connection.
My controller class was internal and routing seems to work differently when working with WS connections. Here's the working class:

public class ShellyPlusDataConnectionController : ControllerBase
{
    [HttpGet("/ShellyPlusDataConnection/OnDataReceived")]
    public async Task OnDataReceived()
    {
        if (HttpContext.WebSockets.IsWebSocketRequest)
        {
            using var webSocket = await HttpContext.WebSockets.AcceptWebSocketAsync();

            var buffer = new byte[1024 * 4];
            WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);

            while (!result.CloseStatus.HasValue)
            {
                string raw = Encoding.UTF8.GetString(buffer, 0, result.Count);


                result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
            }

            await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
        }
        else
        {
            HttpContext.Response.StatusCode = StatusCodes.Status400BadRequest;
        }
    }
}