Connect to device ASP.NET MVC - c#

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#?

You probably won't be able to access the device directly from code running in a web page. Some device manufacturers do make certain APIs available from the web (camera, GPS, etc), but only in a limited fashion. It's highly unlikely that you'd be able to access an arbitrary third-party device from a web site unless it can act as a standard input device (keyboard or mouse) and interact with an input element. For example, if it could fill a text box with a string corresponding to the fingerprint or allow you to take a picture of the fingerprint which could then be uploaded through a file input, then you might be able to use it.
The alternative is writing a secured plugin - Java Applet or ActiveX control - that accesses the device natively and use it to interact via JavaScript with your web page. User's would have to allow the plugin to be loaded and let it have permission to access the device for it to work.

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://127.0.0.1:8080/service");
ws.onopen = function ()
{
};
</script>
Server Sample
static void Main(string[] args)
{
var wssv = new WebSocketSharp.Server.WebSocketServer(System.Net.IPAddress.Any, 8080);
wssv.KeepClean = true;
wssv.AddWebSocketService<Service>("/service");
wssv.Start();
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...");
Console.ReadLine();
wssv.Stop();
}
More about Web Sockets in JavaScript: Html 5 Web Sockets.
Also, a good c# Web Socket Library: C# Web Sockets

Silverlight is a plugin available for some browsers that allows you to run .NET (C#) code on the client. It is similar to Adobe Flash or Java Applets. The development is somewhat similar to developing a WPF app.
Things I would be concerned about are whether you can access the device or not due to security restrictions. Also, see tvanfosson's comment on his own answer. It should be relatively simple to throw together a basic "Hello, world!" app to verify if you can talk to your device from Silverlight.
Another concern is that the last Silverlight support may not be top priority for Microsoft, and it has limited support on non Microsoft platforms.
Another technology you might consider is a ClickOnce application.

Related

Run external code or application on connected client desktop from application that published via RemoteApp or Citrix ICA?

I have desktop app on server, that can be used by clients via Microsoft RDP or RemoteApp or Citrix ICA. And now i need to somehow interact with REAL user desktop from that application running on server in RDP/RemoteApp/ICA session.
Is there exists some server-side API in Microsoft RDP/RemoteApp or Citrix ICA that can be used to implement this?
My app is currently written in C#, but i can easily use COM/WinAPI if needed.
Yes, on Citrix you can use the Virtual Channel SDK:
https://www.citrix.com/downloads/citrix-receiver/sdks/virtual-channel-sdk.html
Microsoft also has something similar if you want to use RDP:
http://msdn.microsoft.com/en-us/library/aa383509%28v=vs.85%29.aspx

Send information to COM port from MVC.NET app

Is there any way to send information from my C# MVC.NET application (that is on a server computer inside a local network) to another PC (in the same network) which has a (fiscal) printer connected in a Serial Port?
My webapp is working ok, and I have a winform app that works ok too. But I cannot connect them.
So I think in sen all the information directly from the web app to the specific IP and COM port.
Is that possible in c#?
Physical hardware are not accessible from web application. You have to create windows services for printing. For the printer it doesn't matter that printer is installed on which port it can be on USB or COM port. If you want to print webpage then simply press Ctrl + P then you get print dialog or you can page.print() javascript method.

Data forwarding server

I have the app for Android and another app for PC, both were written by me. Android app connects to the PC app, and the PC app sends data (in realtime) to the smartphone.
The problem is: if the PC is connected to the mobile wireless network, I can't get its address, so I can't connect my Android app to the PC.
So, is there some simple application (for Windows), that I can use as a server for data forwarding. PC and mobile App will be connected to this server (launched on the station with the static address), and the server will just forward data from one app to another?
Or maybe there are good tutorials for creating such kind of server on C#/Java?
I would use a third pc (a server) that acts as a bridge for Android and PC. I wrote a web service in .NET for a virtual server on the internet. Both Android and PC know the ip address (or the domain name) of the server.
The PC talk to server using .NET native web service call, the Android uses ksoap.
For more infomration about ksoap for android look here:
http://code.google.com/p/ksoap2-android/
EDIT:
I suppose you can have the web server in the pc but you need to configure your modem to forward specific ports to the pc. But if you have no static ip address you need to reconfigure the ip address on Android device everytime your modem is rebooted (or switched off/on). You can also try to use dynamic dns services...
Check this out:
http://whiletrue.blog.com/2013/07/11/smartphone-as-pc-controller/
I've made this with Muzzley. Basically, you already have most of the work done if you integrate with it.
(disclaimer: i work for this project)
On the PC side, you can use the lib to include in you pc app in several languages:
(java) http://www.muzzley.com/documentation/libraries/java.html
(.NET) http://www.muzzley.com/documentation/libraries/dotnet.html
(nodejs) http://www.muzzley.com/documentation/libraries/nodejs.html
On the smartphone side, you can use any of the existent widgets (virtual interfaces):
http://www.muzzley.com/documentation/widgets.html
or eventually make your own:
http://www.muzzley.com/documentation/widgets/webview.html
Example:
You can pull from github several examples here:
https://github.com/muzzley/muzzley-demos/
(check the the webview example)
I hope it helps.

How to open an specific application in PC when connecting a USB?

I want to open an application which is developed in windowsforms using C# in PC when connecting a PDA device via USB connection.
Question is:
How do I check the particular USB device has connected (Eg:PDA)?
how do I launch the specific application when connecting a
particular USB (Eg:PDA)?
I don't understand why you tagged the question with ASP.NET. ASP.NET is a server-side technology, and ASP.NET applications are "started" by IIS in response to an HTTP request (typically from a browser).
What you're looking for is to detect a USB device insertion event, and for that you need an application that runs on the client (and have certain permissions).
Here's a thread that would get you started.

Testing Socket Programming in C# on Windows Mobile 6 Emulator

I need to develop and test an application in Windows Mobile 6 for socket Programming in c#. I have done it in Windows Desktop application (i.e Creating a Windows Console Application that acts as a Server and listens. Then a Windows Form Application that is the client. Has a button and textbox. When i press the button the client gets connected to the server).
Now i have no idea how to check socket programming in windows Mobile 6. (Building a WM6 application that acts as a client and another that acts as sever something like that or should i be using a different approach? I am clueless)
Thanks.
If you just want to test your Windows Mobile 6 client then you can simply connect it to your Windows Desktop application. Click on File > Configure > Network and check the Enable NE2000 option. You can see this blog post to find out how to install the NE2000 driver.
Using Windows Mobile 6 as a client and Windows Desktop as the server is fine. If you want to use the sockets over GPRS or CDMA then you should be aware of the fact your mobile device will likely have a dynamic IP (which can change as the handheld roams to other wireless networks) and will be behind NAT, so it can be difficult to push data out to the handheld without some kind of connection to the server initiated by the client.

Categories