I have a local application which parses data. What i need is to develop a web interface to query statistics and set configurations for the application thats running at all times. Since I am the developer of both applications I have full access to both source.
My main goals here are:
- have a service or app running at all times on the webserver doing most of the work
- have a webUI which will connect to this app and display stats and make configurations
- service/app will be writen in C#
- WebUI will be written in asp or php
- the WebUI must be accessable through the web domain ie: http://server/TestApp on default port 80 were there are other web apps running already.
I know there are ways to do this using a specific port to communicate to eachother, but i would like to avoid this. What is the best way to communicate between these apps?
Thanks,
-Stewart
Use a FileWatcher in C# to watch a file that PHP can read/write to. When something needs parsed, you can try it that way.
You could also give PHP permissions to exec or use the ` character to execute your program which return the result to a varible ex:
$var = `C:\What\Ever\program.exe $param1`;
The local port listener is not a bad idea though.
Related
So I got it to the stage where the .net (framework) console application could run on localhost, but the next issue is exposing it using Nginx.
I looked at many tutorials, but they all seems to be for websites. How can i make it work for a console app?
Thank you.
What do you gain from using nginx in front of it instead of just
opening the console app on port 80 (or preferably 443 witha
certificate)? You will probably need to set up nginx as a reverse
proxy for your app.
I have the console app running on port 1234 because there is already an app using port 80. To be honest, I am not sure why I am using Nginx, I just assume that's what I need, since I have the app running on localhost but I cannot access it from outside. I have set the firewall to accept that port from the domain provider side.
uhm.... what exactly do you mean by "exposing a console application"?
because what you expose with nginx - or any other webserver - is a
website. also: welcome to stackoverflow. i recommend taking the tour,
as well as reading how to ask a good question and what's on topic.
Thank you. I am probably not using the most accurate term. Basically, I just want people to be able to access my app. In my mind, I imaging there is some additional setting I need to do to have it "exposed" to the public (and that's using nginx). I can see the app running on localhost but not sure why it's not public.
please say what you expect a console app 'exposed to the public' would
look like. How would they access it? What tool on my desktop would I
start, ignore the nginx part of the discussion
So I have a loop serving some web content similar to this one.
https://gist.github.com/define-private-public/d05bc52dd0bed1c4699d49e2737e80e7
When I run it, external user should go to a website and see the page content served up by this.
If your console app is a Console.ReadLine() Console.WriteLine() type
thing the only way to expose it simply is to setup and SSH server on
your host system. Then the users need an SSH client to access it. This
is doable via web browser hosted SSH access but thats v complex
solution
You can ignore all the Console Readline and Writeline stuff.
Ok, so the solution is actually quite simple. All you need to do is forward your incoming request to a localhost using proxy_pass, as suggested by #fredrik. The following should be added to the default config file (under nginx):
server {
listen 80;
listen [::]:80;
server_name example.com;
location / {
proxy_pass http://localhost:8888/;
}
}
I'm looking for a way to establish a simple communication between a c# web application and the operating system.
Since i'm working on Silverlight, i get everything i need to create files into any folder on the C:/ Disk. The problem is that we're going to migrate from Silverlight to Html 5 / C#
So i'd need a way to create files FROM any browser to any OS : Windows,Mac,Linux ..
I thought about using Microsoft Active X but that's not cross platforms.
I'm simply looking for a technology/plugin/software or anything that would allow me to do that, the less client interaction would be the best.
I think your need is in conflict with any common sense about security. If there was a simple way to create any file on any computer that loads your web app, just imagine how quickly all sorts of malware would spread.
But going back to your question - I think it will not be simple (btw. was it really simple in silverlight?). What I can imagine is to have some kind of service running on a client PC (the user would have to install it, or it could be corporate policy if your web app is targeted at corporate solutions). Then the service would listen on some TCP port and your web app could send requests to that port with the intent to create particular file with particular content. All the security concerns would be then implemented in mentioned service so that it doesn't get abused by hostile web apps
I have done plenty of C# shell command calls, apps, batch files etc. The other day I was asked if it would be a problem if an executable that I currently run from my web site app, would move to another server on our intranet.
In other words the web site app and the executable that I am running through Process.Start(...) are located on the same box currently - all good there. Now there is a wish to separate the two on two different servers.
I done a few futile attempts to execute an app (located on server B) from server A (where the web site resides).
Is there a way that I have not run cross yet to do this ?
Thanks
PsExec is one way with minimal coding. Using System.Diagnostic.Process, you can call this command:
psexec \\ServerB (path)\myapp.exe arg0 arg1 ...
To control the processes of server A by running an application on server B, you would need an application running on server B that would get controlled remotely somehow.
As an example, let's say server A runs unix, so you could write a application that would connect to server A using ssh, authenticate and then control the processes and whatnot like you do in a shell. If server A does not allow ssh connection, you could write your own application that would be running on server A listening to some connection and commands that would come from an application in server B.
It's quite hard to understand what are your current settings and why would you even want to switch the application from server A to server B, so a little more information would wield you a better answer.
Austin's PSExec approach is probably the easiest approach to executing an EXE on a remote machine, but you may want to consider a potentially more robust solution:
You could modify your command-line app to run as a service and to respond to requests for work and/or data via a WCF (binaryXML/TCP or XML/HTTP) call.
I am writing a Windows application using C#. I am planning on later to allow it to be controlled over the intranet using browser also. So in future we should be able to control it both using the local interface or over the intranet from the browser.
Is there any pre-defined architecture which will allow me to do this? What are the methods of achieving this? I am new to C#/.Net.
EDIT:
The windows application needs to access the communication ports extensively, and needs to be pretty stable and would probably run for some days together.
Thanks...
I can't tell you if a specific package exists that would ease the development. But, if I were to attempt it, after Googling and not finding something already available and meeting my needs, I would likely make my application a WCF host. Create service entry points to accept control messages remotely. You would also need some well-know location where to register your application so the remote system could find it. You should be sure to provide the user with a way of disabling the application remote control feature.
Your host interface will need to run on its own thread to remain performant. Since you are new to C#, and presumably windows forms application development, you will need to read up on how to properly talk to the GUI controls from a non-GUI thread.
Alternatively, you may want to implement your application as two distinct units, one with a GUI that does all the user interaction. It would form service requests to send to the host portion (with no GUI). Your app could then operate locally or be controlled remotely.
One solution I have used in a similar situation has three parts :-
1) Win32 (local) Service
Manages the COM ports and does whatever is necessary with the attached hardware
2) WinForms/Console Application
Runs on the local machine and communicates with the local service via named pipes or TCP.
3) Web Server + Web App
Runs on local or remote machine & communicates with local service.
The local user can shut the WinForms application down and log-off without affecting the service or remote users.
The newest version of Silverlight (the version that ships with Visual Studio 2010) allows what Microsoft terms the "Out Of Browser Experience" (OOB for short).
This allows the user to set up the Silverlight application as a desktop application as well as running through a browser.
Rudi Grobbler has just blogged about how he went about setting this up on his PC.
Hey guys, I was working on a simple chat program to brush up on my C#, and ran into a roadblock. I wanted to allow one computer to broadcast its location, and the other to find that computer, and display it (and any others) in a list.. Just a push in the right direction would be great,
Thanks,
Max
Mono.Zeroconf is a .NET library that provides common zeroconf opertations - service publish and discovery. It uses Apple's Bonjour for Windows as a transport on Windows.
Developers can publish services that will be exposed to other computers on the local network and also query the local machines on the network for services that could have been exposed.
See Peer-to-Peer Programming with WCF and .NET Framework 3.5.
All you need is to share destination PC. and then run your web-based application on the target pc IIS.
Updated Part :
If you have awindows application and want users use that application youhave some solution
create a Login form for your application
use from MarshalByRef object and create a Channel between user andaplication
create a MSI (setup) and run it from server (in entire Active Directory).this will install one application in each client
create a simple dot net setup. justRight click onyour windowsproject in VS and then select Publich, in the wizard walk through creating a network application
I think the last option is closest one to your request
Use AD (Active Directory)? Or some such [which would serve as] central messageboard mechanism - maybe even MSMQ?