Blazor and Web Serial Api

Ashley Davy 6 Reputation points

When will Blazor support Web Serial Api for use on the client side with WebAssembly? I have a need to communicate with a Com Port from the end users browser. I thought that since I had enabled the permission through chrome://flags/#enable-experimental-web-platform-features that I could use System.IO.Ports and then call SerialPort.GetPortName() to get a list of available Com Ports. When I make the call GetPortName() I get an exception. How can I get this to work with C# code / WebAssembly?

A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,496 questions
0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. Michael Wang-MSFT 1,061 Reputation points

    Hi, @Ashley Davy

    As far as I know, it's unable to access SerialPort via Blazor WebAssembly. And I already post answer with same thread here. Please check.

    0 comments No comments

  2. Duy Hung 1 Reputation point

    If you're developing your app for your customer you can:

    1. develop windows-service that accepts http requests
    2. Share the serial somehow on the ethernet so that the server can connect to the KNOWN ip address
    0 comments No comments

  3. Krunoslav Ostrouška 1 Reputation point

    In JavaScript:
    Maybe it is possible to workaround using JavaScript functions in Blazor.
    Or find an colleague who can do it in JavaScript directly.

    0 comments No comments

  4. Bruce ( 61,186 Reputation points

    Webassembly is a sandbox and has no access to the dom, network, files or browser apis. You need to send a message to JavaScript (blazor interop) to perform this.

    0 comments No comments