Blazor Client-side. Is it possible to access the Serial ports (COM) from browser?

Nikolay Renziglov 21 Reputation points

Hi there
Is it possible to communicate to a Serial ports of a client machine making use of Blazor Client?
If yes, any clue or links?

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

2 answers

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

    Hi, @Nikolay Renziglov ,

    Blazor WebAssembly doesn't support to access local serial port on client. You will get the error below.


    It's danger and illegal for accessing the serial port from client side. You could try another approach:

    1. Write a Windows Service (I assume your machine runs Windows), configure it with necessary privileges. You will have to install something on the machine anyway. The service can be implemented in any language.
    2. Add HTTP(S) server capabilities to it and choose communication protocol over HTTP. You could use JSON, Ajax, WebSockets, SignalR, etc.
      · Send data byte from serial port to /.
      · Recieve command byte from serve to serial port .
    3. Build a web server to process the data with client.
    4. Create a front page to display your data and control it.

    If the answer doesn’t solve your issue, please provide more details of error that will help us track down what’s happening.
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,
    Michael Wang

  2. John Flaherty 1 Reputation point

    You can in in Chrome since 89. Maybe chromium based but I haven't looked. See You'll need to write js adaptors.

    0 comments No comments