Mohamed Al-Hosary Mohamed Al-Hosary - 1 year ago 141
ASP.NET (C#) Question

Connect to device ASP.NET MVC

I am new to ASP.NET MVC, i have to develop a web page that connects to a fingerprint device using its SDK (C# SDK), captures fingerprint image and display live preview from the device.

This page is working fine if the device is connected to the server that hosts my page.

The problem is when a client opens the web page and connects the device, the code that is written to connect to the device runs on the server so it doesn't detect client devices (Device SDK is installed on the server, so it detect device only if it is connected to the server).

Can i run device code on client side using c#?

Answer Source

For others who need help: I implemented a custom way to connect to USB devices connected to client workstation from ASP.NET MVC web pages. Using Web Sockets, you can create your own client desktop application (c#) to connect to the device. This desktop application will be a Server for Web Sockets and then in your web page, you can implement a Web Sockets client to connect to the desktop application.

Client Sample (JavaScript)

<script type="text/javascript">

    var ws = new WebSocket("ws://");

    ws.onopen = function ()

Server Sample

static void Main(string[] args)
            var wssv = new WebSocketSharp.Server.WebSocketServer(System.Net.IPAddress.Any, 8080);

            wssv.KeepClean = true;


            if (wssv.IsListening)
                Console.WriteLine("Listening on port {0}, and providing WebSocket services:", wssv.Port);
                foreach (var path in wssv.WebSocketServices.Paths)
                    Console.WriteLine("- {0}", path);
            Console.WriteLine("\nPress Enter key to stop the server...");


More about Web Sockets in JavaScript: Html 5 Web Sockets.

Also, a good c# Web Socket Library: C# Web Sockets