Share via

With ASP.NET Framework, can I use SerialPort and SignalR together?

MERVE DEMİR 0 Reputation points
2023-12-23T08:01:17.9333333+00:00

I am developing a website using ASP.NET Framework. The website will display real-time data received through the SerialPort. To achieve real-time functionality, I am attempting to use SignalR. However, I'm unsure whether SignalR and SerialPort can be used together with the .NET Framework. I have been working on this for a while and couldn't find any resources. Can you please help? Thank you

Developer technologies | .NET | Other
Developer technologies | ASP.NET | Other
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 31,181 Reputation points
    2023-12-23T11:00:33.8466667+00:00

    can I use SerialPort and SignalR together?

    SignalR runs in the browser and the Hub runs on the server. The browser cannot interact directly with the serial port. However, this is an experimental browser API that can access the serial port.

    https://developer.mozilla.org/en-US/docs/Web/API/SerialPort

    ASP.NET (server side code) and the Hub can interact with the serial port but it only works if the device is attached to the web server's serial port. This setup works on the local machine where the computer is both the client and web server. It will not work if the application is deploy to a host on the internet.

    In short, your approach is not going to work unless the application runs on your development machine. Keep in mind, that ASP.NET web forms uses a post back to execute code. The only time you'll see updates is when server side code has executed (Post Back) or AJAX calls (JavaScript).

    A Windows application or service would be a much easier solution.

    0 comments No comments

Your answer

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