Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
scroll top