I have a C# form application that has different functionality. Additionally I want to add another service to the existing project which is hosting the webpage "CameraCapture.html" page over Local Area Network as a web service in order to be viewed from another client on the Network.
For this purpose I have added one form "frm_cameraServer_monotor" and two Buttons in this form, btn_StartServer and btn_StopServer, which to start serving "CameraCapture.html" and to stop serving it. My IP Address on LAN is: 10.140.191.200 (static).
I don't want to use any web server like Apache and ISS to be installed and configured. Just I want a server service to existing project.
Any one can understand and help me in this topic, really very appreciated Thanks.
I want to start web-service but without web-server
If it is just a plain HTML without back-end but not a web-service, then you can create a shared folder and open it as a file from your network. HTML and front-end JS scripts will work well. However, the link will be like:
file:\\COMPUTER-001\Camera\CameraCapture.html
If it is ok for you, then you can easily do this without web-server.
You surely cannot make it work this way without any HTTP-server:
http://COMPUTER-001/CameraCapture.html
Is it worth it?
Install a simple web-server, you even won't need to configure it if a single HTML file is everything you need.
If you want to host an asp.net site on your application (winforms/service/wpf/whatever) you can use CassiniDev
Then simply publish your web project to your filesystem and use:
CassiniDev.Server server = new CassiniDev.Server({port number}, {publishedSitePath});
server.Start();
Related
I'm currently working on an ASP.Net MVC4 application to automate a production workflow.
my client would prefer the solution to be "zero footprint", so completely running in browser.
One of the issues I can't imagine how to handle is to get data from a weighing scale connected to the client's serial/parallel port from within the page.
(Obviously this can't be done from the web backend ... )
I've been digging around, assuming this could be possible through javascript/jquery, but since this is running sandboxed within the browser, I'm assuming to get stuck that way ...
One of the approaches I considered was writing a self-hosted WCF webservice to run on the client that has the scale attached (hosted by a windows service or console app or so) that exposes the scale readout. Theoretically, that would allow me to consume the webservice in the IIS backend in my MVC C# code and serve it back to the client.
The only issue with this approach is that this would require the application to be hosted locally, where we'd prefer to have it hosted by an external provider.
Is there no way to handle this on the client side exclusively?
I can't imagine I'm the first person running into this, but I can't seem to find what I'm looking for by digging around on the web ...
Any thoughts ?
Thanks in advance! Stijn, Belgium
You absolutely must have a process running on the system that has access to hardware to support reading from any hardware interface. You have a lot of options there- it could be a local service running that can read the serial port and expose a simple HTTP endpoint to the browser. You can also do ActiveX-style controls for IE or browser extensions for Chrome:
http://developer.chrome.com/apps/app_usb.html
Just as a follow-up:
I ended up creating a user-control that reads out the COM-port through PInvoke of CreateFile to open the COM-port ...
Works great, no hassle with an external process running on the client etc ...
Does require full trust in the browser, but that's acceptable, since it'll run on clients under our control ...
grtz,
Stijn
I am working on application, which is divided in Client and Server part. Basically Server reads the TASK Database table, and perform the requested task and update database once complete. On other hand Client create Task entry as user desire.
Now some task are to read files which will be presented on Server machine, however we need Client to locate those files. For this I need to show directory structure of Server machine to client. So they can navigate to Folder structure and select relevant folder and files as per requirement. Also, at one stage we need Client to able to download the Files from Remote server.
On Server end we currently have Windows Service as it is mainly a background work it needs to perform and on client end I am using WPF based GUI.
Now, I am not sure what method I should use to access folder structure and to allow download of file. I have two options as I think
I create a TCP/IP Connection between my Client machine and Server machine. Then Server machine will pass Directory Structure as JSON To client and I show it on Custom build Tree View.
I create a Web service on Client end, and then consume that web service at client.
I can definiately use either of method to download files if I Can access folder structure. Now I find some drawback on either method.
on TCP/IP connection I have to maintain the connection between client and server which is otherwise not required as both application work independently. Infact with it's current architecture we can use application from outside domain or LAN.
With #2 solution, I am not willing to use default web server, as I am not sure if server are used for other parts in organization. So, I want to club this webservice with my Windows Service in background, is it possible if so, how? This give me fix address to access the service as well. But if I build on general webservice then I fear how I do the Directory structure reading does IIS or Apache allow reading of complete file structure?
Which solution is better and of course easy to code :) and maintain.
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.
Could you provide example of JavaScript function for starting up application installed on your computer from a web browser (eg google chrome 4). It particular if .Net APPs have any special simplifying this process apis of out there are some libs for such staff, please share link with us.
so how to create and store in run on start up programs a small local server which would handel some local urls like http://localhost/maAppServer/MyAppCalculator/Start for starting apps that have written in its config file their names and local urls on install?
So how to start up your C# .NET app\program from web browser?
I don't believe its possible in Chrome, starting an EXE on a users computer could be considered a security violation. Some ActiveX, and file:// links in internet explorer may work. Also, OneClick deployment may do something similar to what you are after (not exactly though I don't think, and I believe they require an add-in which may not be available for Crhome) http://www.15seconds.com/issue/041229.htm
I'm not sure what you're asking for. You can start an application on your computer just by linking to it in the HTML page. However, if you need to pass data to it, then it's a different matter altogether, although it's still simple.
An example is what www.nexon.com does with it's MMORPG, MapleStory. You log on to the website, and the web page starts the game after the authentication. Another example would be the magnet links on file-sharing sites.
You need to create a protocol handler, it can be in any language like C++/C# and register it on the client's computer. Like so - http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx
Then, just use the protocol you built to pass on whatever data necessary. You can add a link that can be clicked, a button, Response.Redirect() from the server, whatever you like.
So, here is a deal.
I have client-server application(dotNet remoting). Client side has few trackbars, checkboxes, buttons and picturebox. Server is a console application and does only calculation from client. Client's picturebox make some visualisation of calculation in picturebox. All calulations and relative classes are in dll file.
Now I have to embed client application in web site. All kind of technologies are accepted, but I want to minimize forces applied to embedding. So, what is the best way to do embedding?
What about SilverLight or Flash?
You need to create a web site that accesses your remoting server and renders output as HTML. I seriously doubt that you will be able to get remoting working inside a browser environment, even using something like Silverlight.
If you don't want to use a full blown web server then use the .net class HttpListener in your server application to create an embedded web server.
If you want to take a C# application and access it through a web server, look into iHttpHandler. You need to compile to a DLL, and configure your IIS server.
There are a number of tutorials on the web. One is: http://www.codeproject.com/KB/aspnet/CustomImageHandler.aspx