I'm trying to get ideas, on how I can pass parameters from a website, to a C# console application. The website is built in .NET. The C# console application requires some arguments to be passed to it in order to trigger certain functions. Is it possible to pass in these arguments from a website?
-
Please specify where you "console application" is running (server or client or somewhere else altogether). – Alexei Levenkov Jan 15 '15 at 22:49
-
The console application can go GET the parameters from a web site (webapi, rest, json or some such) but security will prohibit you from calling a local console application from a web site. – crthompson Jan 15 '15 at 22:50
-
3Need more context so we know what you're trying to do... – trousyt Jan 15 '15 at 23:06
-
1Classical [XY problem](http://xyproblem.info/), You think *you can solve your problem with passing some parameters to Console app*, and ask a solution for this instead of asking your *real* problem. – EZI Jan 15 '15 at 23:17
1 Answers
There are a few scenarios, and we don't know which is the case, so I will outline each one:
Scenario 1) If your console application is running on the server, you could start a process with Process.Start()
(assuming you have your server configured in a manner where this will work, see this SO question and first answer).
Scenario 2) If your console app is running on a client computer and you have a hostname or ip that points to the client, and firewalls do not prevent communications with the client, then you could open a port and communicate with it. This is tedious and probably not worth the time though; instead, I'd suggest (as @paqogomez commented) setting up a web api or something to retrieve the parameters. Because you already have the webserver configured, you shouldn't need to worry about additional firewall configuration, and you can retrieve the values with a simple webrequest or web service.
Scenario 3) If your console app is running on a client computer and you do not have a hostname or ip that points to the client, then you cannot send data to the client; however, you can still have the client retrieve the data as explained in Scenario 2.