Reputation:
I want to know how to run my console application from ASP.NET, which is in one solution.
I want to run and stop the application.
Upvotes: 0
Views: 5335
Reputation: 21192
On a client machine or on the server ?
if you are thinking client machine there is no way !
anyway this is how you do it on the application's server
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
Upvotes: 4
Reputation: 61518
Just start it like you'd start any normal EXE.
var proc = Process.Start(@"C:\myconsole.exe");
You should place the console EXE file at a proper place though.
And you can end it with:
proc.Kill();
...
Note: that starting the process on a single request might not be a good idea. It might be better to start it on another thread and lets it spin so you can response to your users faster.
Upvotes: 2