简体   繁体   English

ASP.NET流程开始

[英]ASP.NET Process Start

I made new project (ASP.NET MVC Web Application) using Visual Studio Web 2013 Express Edition. 我使用Visual Studio Web 2013 Express Edition创建了新项目(ASP.NET MVC Web应用程序)。 Loading index page, redirects and everything works fine, except that in some part of my code I need to create Process and execute it, wait for it to finish, parse output of that external application and show that output to the user. 加载索引页,重定向和一切正常,除了在我的代码的某些部分中,我需要创建Process并执行它,等待它完成,解析该外部应用程序的输出并将该输出显示给用户。 However I get nothing. 但是我什么也没得到。 While debugging the code line by line: 在逐行调试代码时:

ProcessStartInfo info = new ProcessStartInfo();
info.FileName = Tool;
info.Arguments = filename + " " + avArray;
info.CreateNoWindow = true;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;

Process p = new Process();
p.StartInfo = info;
p.Start();
p.WaitForExit();

Process exits immediately, someone would say it is pretty fast program, but application needs at least 5 seconds (sometimes 20 seconds) to complete. 进程立即退出,有人会说这是一个非常快的程序,但是应用程序至少需要5秒钟(有时20秒钟)才能完成。 What I think is happening is that process is not created in the first place, as my IIS settings or whatever other settings are not allowing me to run this EXE. 我认为正在发生的事情是该过程不是首先创建的,因为我的IIS设置或任何其他设置都不允许我运行此EXE。 What do I do to change this? 我该怎么做才能改变这种状况?

I've been trying to this for the past 2 weeks, I've read probably every post about it, and tried every solution suggested. 在过去的两个星期中,我一直在尝试这样做,我可能已经阅读了有关它的每篇文章,并尝试了建议的每种解决方案。 I am choosing to write on this post since it is the most recent. 我选择写这篇文章,因为它是最新的。

First of all, I am using VS2013, testing on IIS Express, and then on IIS 8.5., the webpages version is 3, and the target framework 4.5. 首先,我使用VS2013,在IIS Express上进行测试,然后在IIS 8.5上进行测试,网页版本为3,目标框架为4.5。 And I am assuming that (as with my case) the goal is to launch the process on the server. 我假设(与我的情况一样)目标是在服务器上启动该进程。

What I learned: 我学到的是:

  1. Using IIS Express should allow you to run the process without problems. 使用IIS Express应该可以使您顺利运行该过程。 You can try to allow it to launch the window, or start your process through the shell just to be sure that it is actually launching (a shell window should popup and close). 您可以尝试允许它启动窗口,或者通过外壳启动您的进程,以确保它确实在启动(外壳窗口应该弹出并关闭)。 If this happens, verify that you are giving the correct path to to your program, etc. So far so good. 如果发生这种情况,请验证您是否为程序提供了正确的路径,等等。到目前为止一切顺利。

  2. Going into the IIS 8.5 is a totally different matter. 进入IIS 8.5是完全不同的事情。 Theoretically, the bad way of doing it should be preatty straight-forward: you create an app-pool for that server, give it a high privileged account (local system or network system, for instance); 从理论上讲,这样做的坏方法应该是简单明了:为该服务器创建一个应用程序池,为其分配一个高特权帐户(例如,本地系统或网络系统); go to AdministrativeTools->Services->IIS, LogOn tab, and allow interaction with the desktop. 转到管理工具->服务-> IIS,“登录”选项卡,并允许与桌面进行交互。 You should be able to do the same as in IISExpress, but in my case is just the same as with a low privilege account. 您应该能够执行与IISExpress中相同的操作,但就我而言,这与使用低特权帐户相同。

  3. I actually started by trying just to use impersonation, but also was not able to launch the process with IIS8.5. 实际上,我最初只是尝试使用模拟,但也无法使用IIS8.5启动该过程。 EDIT: I retried this again today, and the api won't even run if I enable impersonation. 编辑:今天我再次重试了一次,如果启用了模拟功能,api甚至不会运行。

I've spent more time than I would like with this, any input on why I can't get this to work properly with IIS8.5 (@clzola: IIS Express should do the job) is very welcome. 我花费的时间比我想要的要多,对于任何为什么无法使它与IIS8.5一起正常工作(@clzola:IIS Express应该可以完成工作)的任何意见都非常受欢迎。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM