Blazor and Web Serial Api

Ashley Davy 6 Reputation points
2021-03-05T15:45:27.477+00:00

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?

Developer technologies | .NET | Blazor
0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. Michael Wang-MSFT 1,061 Reputation points
    2021-03-08T06:54:01.35+00:00

    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
    2021-06-11T08:43:13.757+00:00

    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
    2021-11-15T11:19:52.773+00:00

    In JavaScript: https://dev.to/unjavascripter/the-amazing-powers-of-the-web-web-serial-api-3ilc
    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 (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2021-11-15T15:57:42.097+00:00

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.