how to access usb port of client pc from web app - c#

I have a web app. now I want to add "present and absent by finger print" to this. everything work fine in localhost (add finger,remove finger and etc). I send device port name to functions to do jobs.
but after publishing project I recognized that it can not find port in client's pc.
now I want to now how can I access specific port in client's pc after publishing web app?
PS:if you need to know part of code just say it to show you, thank you

Browsers don't let you to do it on purpose. However, you can create ActiveX objects, plugins or browser extensions to do it.
For example you can check this

I have understand the best way is windows application, so I did my job by creating c# windows application and did my job as well as I wanted.

Related

Can a local web server be created for Windows 8 Surface RT

My goal is to run flash locally on a Windows Surface RT tablet. From research, I have found that for websites to run flash, they have to be whitelisted on Microsoft's website. Through further research, I have found how to hack the whitelist to add any domain:
http://www.redmondpie.com/how-to-enable-flash-for-any-site-in-windows-8-rt-metro-internet-explorer-10/.
However, I cannot add the local file system (i.e. C:\ or file:\\) as they are not domains. One solution, I have though of is by using localhost. How can I write a web server to run on Windows 8 Surface RT, or can it be done?
In C#, I know you can use System.Net.HttpListener: http://www.codehosting.net/blog/BlogEngine/post/Simple-C-Web-Server.aspx. Is System.Net.HttpListener supported with Surface RT? If not, what are alternative solutions to play flash locally?
Theoretically, it is possible. You need to use StreamSocketListener to get a StreamSocket. Then you handle http input from that socket (tons of work), and send back your response. I've made my protocol work. One thing you might need to pay attention is that you might need a second machine to send the http request. I use IE from another PC to send the test request. Win8 network isolation won't allow tcp connections between 2 apps of a same machine...

How to properly execute C# file over local network?

Overview
C# File - Users PC
PHP Server - Hosts Webpages for application
Server and Users PC on local network
I have a c# file that reads weight from a USB scale. How would I trigger this file to run so it feeds into my program. The problem is I am using PHP to host our webpage/application so its not running client side and the scale is not hooked up to the server but to the clients PC.
The C# script would have to be on the clients in order to read the scale so how would I trigger this to happen?
Is this even possible and if not what would be a better way?
Important Edit
I was able to run the Scale Script (C#) when I wanted by having PHP and C# use TCP sockets.
The C# would listen for PHP to send something and when it did it would read the scale and send this information back to PHP becuase PHP was listening for a response. Mixed in with a little Ajax and it updates in the web browser.
Gave Chris Credit because he was the most helpful with answering my questions
It sounds like what you really want is for the client application to submit the data to the website itself, and the most suitable approach is probably to expose a web service from your server.
This service should accept weight data, along with some sort of customer key or whatever, to correlate the records correctly on the server side. I've never created a web service in PHP personally, so I can't give any advice on the implementation of that, but it is fairly trivial to hook a C# client app up to a web service once you've exposed its metadata (assuming you use SOAP).
you can't start C# application from a web page in a way that'll work in every browser every time. BUT, you can have some workarounds:
Use ActiveX component that read the data in the client and upload it to the server. the biggest cons is that it'll only work in Internet Explorer
use Silverlight client application that runs on elevated mode (v4) and upload the data to your server.
refer your clients to download application (the C# application you wrote about) and run it - this application will upload the data to your server.
hope this helps.
C# isn't a scripting language, it's a language that compiles into executable binaries or libraries. You won't be able to execute C# code on the client's computer via a website because C# code needs to be compiled before it can run.
Presumably what you really want is for your compiled C# binary to be executed on the client's machine via your website. You won't be able to easily do that. There are a lot of security measures in place to prevent browsers from running programs on your computer. There may be ways to hack around these security measures by using plugins (such as ActiveX), but it's not something that will be a one-liner.
Edit: I think you need to step back and think about what you're trying to do in a broad sense. You're trying to create a website that can read information from a user's USB port. This is the type of thing that browsers are designed to prevent, and for good reason. I wouldn't want random websites to be able to access peripheral hardware without my explicit permission. If you want this website to function the way you're expecting, you're going to have to seriously think about the security implications. You'll need some kind of client-side code (ActiveX, Silverlight, ...), and the user will need to explicitly give permission to for this all to happen. It won't be easy, and it won't be automatic. And I'm damn glad that's true.

Local Testing and Debugging Facebook iframe app (Windows Azure)

I wonder what the best way to test and debug facebook iframe applications locally (using the facebook c# toolkit and the azure toolkit)?
When i try to debug it's always starting the Compute Emulator on a different port.
Basically i want to have a special facebook iframe app pointing to a specific port on localhost (e.g. http://localhost:81) and after pushing the debug button that my app url (e.g. http://apps.facebook.com/myspecificappdev) is being started in my browser (with debug functionality).
I found this thread but unfortunatly this didn't help me a lot: http://azuretoolkit.codeplex.com/discussions/207487
What's the best way to debug such applications? Is their maybe a sample project which already has that part set up correctly?
Ok, here is what we do (at Thuzi). We set up an dedicated IIS web site for our code. We create a bogus domain like fbapp.mycompanysdomain.com and then we edit your machine's (or other machine's) Hosts file to point to the proper IP address. When we set up the site in IIS we use a host header which means that we don't need to worry about port numbers. When we debug we simply attach to the process.
So you point your web browser to the FB URL and it should always land on your web server (whether you are debugging locally or not). I know this sounds like a little more work, but it ends up being so much easier in the long run and better reflects what will ultimately happen. I realize if you are using any kind of storage then you will need to start that up, but it's still a lot easier this way..
If your app is simply a website, then you don't need to run the compute emulator to run it. I would setup the site so that it runs on IIS on a specific port, then debug the website project, not the cloud project.
There is a bit more to it than just that however. If you're using development storage then you'll need to start that yourself as it won't automatically be started when you debug the website. If you have a RoleEntryPoint class then you need to be aware that none of that code will be called. Also if you make use of anything in RoleEnvironment (like settings) you'll need to put a wrapper around those items so that they'll still work when not running under the emulation environment (RoleEnvironment.IsAvailable is very useful for detecting this). A setup like this is very useful during development because when you make small changes to CSS of JavaScript you don't need to restart the compute emulator to see your changes.
You're on the right track. You need to create a new facebook app and point the iframe / canvas / tab url to localhost with the specific port cassini chose for the project.
What I did to ensure the the windows azure app stays on the same port:
I placed this as a pre-build event:
"C:\Program Files\Windows Azure SDK\v1.4\bin\csrun.exe" /devfabric:shutdown
This makes it better but it's still switching port sometimes

Best way of executing code over the internet

basically, I am needing to execute a program on the viewers computer through a website. This program must be capable of talking to device drivers however, which makes it an unlikely candidate for activex. The website will only be used by clients(as in, it's not a public site) so having to change security settings isn't too big of a deal.
Also, we could possibly have them install an application on their computer, and then when they click a button on the website this activex control just executes the application they already installed to avoid device driver problems..
Does anyone have any ideas on how to do this well? I have a feeling activex won't just let you arbitrarily execute local applications. Also, it is preferred to be possible to do without certificates and signing(though it will eventually be over https)
(it's only tagged C# because that's the programming language to be used on both the client and server)
If you only need to tell the application to simply launch or launch with certain data, you can look into registering a protocol handler and create links, that the user can click, similar to myapp://the/data/you/need/to/send.
It sounds like you will have control over the client and server sides, so why not use WCF and set up the client application to connect to the server via a duplexed communication. On the server side keep a list of the clients that have connected to it and then when you need to trigger the client side code it will iterate over the list of clients and send the message to execute the code. And when the client disconnects it will be unregistered from the server.
See this link for more information on the duplex services.
Also, we could possibly have them install an application on their computer, and then when they click a button on the website this activex control just executes the application they already installed to avoid device driver problems..
Ding ding. That's pretty much what you'll have to do.

Printing Server Side from .Net (without WinForms)

Hey printing junkies need some pointers to send me in the right direction for this development.
I am developing an epos system for a local shop which we are later going to tie into an ecommerce site.
The front end of the epos system is going to be WinForms so we can handle USB devices easily and we are going to use a WebForms/MVC admin console.
One area we are inexperienced in is printing. We need to print barcodes, and wish to do this via the admin console (web based).
So (finally) the question. Where do we start looking for code that will allow us to print directly to a connected printer from the server (IIS) instance of .net from the webforms.
System.Drawing.Printing
http://msdn.microsoft.com/en-us/library/system.drawing.printing.aspx
Creating the document is a lot like creating a dynamic image. I have not actually sent a document to the printer from a web app, but I don't see why you couldn't.
Your Web app will probably have to use remoting to connect to a Windows service running on the same machine (or pick your favorite IPC mechanism—perhaps a queue in a database). This service can run in an full trust context and should be able to print for you.
You can set up a local printer, that just passed traffic through to the network printer. This is easier to set up that printing direct to a network printer. See link text

Categories

Resources