我想知道如何从ASP.NET运行我的控制台应用程序,这是一个解决方案。
我想运行并停止该应用程序。
答案 0 :(得分:4)
在客户端计算机上还是在服务器上?
如果您认为客户端机器没有办法!
无论如何,这是你在应用程序服务器上的方式
Var process = new Process();
process.StartInfo.FileName = "Notepad.exe";//in your case full path with the application name
process.StartInfo.Arguments = " ";//arguments
process.Start();
// Do your magic here
process.Kill();//Dont forget to kill it when you are done
答案 1 :(得分:2)
就像你开始任何正常的EXE一样启动它。
var proc = Process.Start(@"C:\myconsole.exe");
您应该将控制台EXE文件放在适当的位置。
你可以用以下结尾:
proc.Kill();
...
注意:在单个请求上启动流程可能不是一个好主意。最好在另一个线程上启动它并让它旋转,这样你就可以更快地响应给你的用户。