I have an Angular application with a table, and I'm considering having the console application take the name of C# programs that the user can run.

I was thinking of passing the name or code of the console application to a ASP.NET WebAPI controller that will run the console application.

However, I'm not sure if it's the "right" architecture for the controller in the ASP.NET WebApi to call different console applications. Or if I should have a layer between the WebApi and calling the executables.

Please let me know if that's the right way or should I think of a different approach.

  • do you have the code for the c# console apps? – Ewan Dec 5 at 22:07
  • No, I haven't created the c# console apps. But the apps will either produce csv files or email files. – rds80 Dec 5 at 22:09
  • If you haven’t created the console apps, why not make dll’s (or NuGet packages) instead? – Rik D Dec 5 at 22:18
up vote 3 down vote accepted

Its not a great idea to have a web api call an executable. There are a number of issues you have to consider.

1: Security

We are basically exposing the command line to the web. Any flaw in the way we start the console application might allow a malicious user to run some unexpected command

2: Running out of threads

With a web app we expect each request to be answered promptly, but we dont know how long the console app might run for. We could end up running out of resources

3: Permission issues

By default the console app will run as the same user that the app pool is running as. Will it have enough permissions? will it have too many permissions? you mught need impersonate a different user when you execute the app.

4: Will it close?

Not so much of a problem with a console app, but try firing up something like excel and watch your memory disappear

Your best option is to take the business logic out of the console application and use it directly as a library. But if you dont have the source code this might not be possible.

Look for alternate products which offer an api or library

If you really have to run console apps though, it can be done. Just be extra careful

  • I should've mentioned that this is an intranet website and the website, DB, web services are on 1 VM. However, these are very important points that I'll have to remember for an internet web app. – rds80 Dec 6 at 14:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.