【发布时间】:2018-03-01 06:30:07
【问题描述】:
我需要根据需求启动我的 OWIN 自托管控制台应用程序。这个需求是在一个单独的 ASP.NET Web API 中决定的,它通常在调试模式下托管在 VS 的 IIS express 下。但即使没有收到错误,我也无法从这个决策 ASP.NET Web API 内部提示命令窗口。下面是我只调用命令提示符的测试代码,直接写在我的决策 Web API 控制器中。
using (Process p = new Process())
{
// set start info
p.StartInfo = new ProcessStartInfo("cmd.exe")
{
RedirectStandardInput = true,
UseShellExecute = false,
WorkingDirectory = @"d:\"
};
// event handlers for output & error
p.OutputDataReceived += p_OutputDataReceived;
p.ErrorDataReceived += p_ErrorDataReceived;
// start process
p.Start();
// send command to its input
p.StandardInput.Write("dir" + p.StandardInput.NewLine);
//wait
p.WaitForExit();
}
所有应用程序都在同一台机器上。在 ASP.NET MVC 控制器事件下运行的上述代码没有得到任何输出,但如果在控制台应用程序下运行,相同的代码会给我一个预期的命令窗口。
Is there any restriction to prompt command window under an ASP.NET Web API context?
【问题讨论】:
标签: c# asp.net asp.net-mvc owin self-hosting