Riaan Badenhorst
Riaan Badenhorst

Reputation: 51

Accessing a console application from web page

I've recently created two C# console applications. The first transforms a bunch of command outputs into an XML, and the second transforms the XML into a Word document using a template.

I'd like to know how I could get this onto the web, i.e having a web page where the command output can be uploaded, the two step conversion executed, and finally the Word document made available for download.

Should the web page be created in ASP.NET or are there other (better) options? Do I need to rewrite the console applications in some other format?

Upvotes: 0

Views: 440

Answers (1)

m-a-r-c-e-l-i-n-o
m-a-r-c-e-l-i-n-o

Reputation: 2672

This question is fairly broad, with plenty of room for novel sized explanations, but here's a brief highlevel walk through of what likely needs to happen to achieve the proposed results (language agnostic):

  • Get a hosting provider that allows users to spin up their own machine (i.e. AWS).
  • Spin up a machine that is compatible with the "console" programs in question.
  • Install "console" programs on machine.
  • Install a programming language (i.e. Node.js, PHP, ASP.NET, even C# could do) on the machine.
  • Install a web server (i.e. NGINX, Apache) on machine, configure it to serve public requests and run with chosen language.
  • On server request, execute appropriate commands from within the chosen language. Languages typically come with a exec method (i.e. in node.js: require('child_process').exec(command,options,callback))
  • Get the results of said commands and send it back to the client. Alternatively (for downloads), write the result to a path on the system that is publicly available to the internet and redirect the user to that url (additional configuration might be required to make sure the browser downloads the file as oppose to just serving it).

The steps above should get you pretty close to that you want. As for your questions:

Should the web page be created in ASP.NET or are there other (better) options?

The "better" options is whatever you feel most comfortable with at the moment, you could always change it later with reasonable effort (assuming that your "console" apps are not unsuspecting unicorns).

Do I need to rewrite the console applications in some other format?

No, unless you have strong reasons to do so (i.e. multi environment compatibility). You could also rewrite to significantly simplify (i.e. bypass working with a CLI and do everything in C#).

Try thinking through these high level steps, begin working on a implementation, and post more specific questions here on StackOverflow when you get stuck.

I hope that helps!

Upvotes: 2

Related Questions