Calling an application from ASP.NET MVC

帅比萌擦擦* 提交于 2019-12-11 07:45:48

问题


Im trying to see if it is at all possible to call an external (console) application from an ASP.NET MVC app. They will both be build and deployed on internal servers, and both will use a custom form of security, validating the user VIA AD before anything executes, so Im not overly worried about the security risks. Basically, Im trying to build a web based front end for an application so it can be kicked off "anywhere". The web based front end will basically collect all the parameters and pass them to the application at run time.

Any thoughts?


回答1:


Create a Process object, and give all the information in the ProcessStartInfo, then just start the process.

Something like:

        Process notepad = new Process();

        notepad.StartInfo.FileName = "notepad.exe";
        notepad.StartInfo.Arguments = "stackoverflow.txt";

        notepad.Start();

That's gotta work when you give your worker process enough rights to start the process. We actually use something the same in one of our applications.




回答2:


If you can't have your web app to run processes - I don't know, maybe because ASP.NET service has insuccifient rights, etc - you can have another process run in background, waiting for requests to run console apps. Your ASP.NET MVC app will then communicate with it using pipes or another IPC stuff.



来源:https://stackoverflow.com/questions/1765907/calling-an-application-from-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!