进程工作者不在IIS 7上工作

时间:2011-08-20 06:37:03

标签: c# asp.net-mvc iis-7 system.diagnostics beyondcompare3

让我们看一下场景,我开发了一个显示.xml文件列表的Web应用程序(ASP.NET MVC),我们选择了两个.xml文件进行比较,并使用比较实用程序,如Beyond Compare 3。 / p>

基本上,我有一个在System.Diagnostic.Process上运行的Scrapt文件(Beyond Compare 3 Script),并根据脚本生成不同的报告文件。我想在显示运行时生成的差异报告的过程中使用该脚本。当我从Visual Studio运行应用程序时,它运行完美并显示预期的差异文件,但是当我在IIS Web服务器上部署此应用程序时,它不会生成差异文件,只是将输入文件显示为输出文件。

以下是启动过程并生成Beyond Compare结果文件作为输出文件的方法。但是下面的代码在Visual Studio开发服务器上运行,但它不适用于IIS(IIS服务器上的网站部署)。

public string GenerateSortedXMLFile(string inputfilepath)
{
       string outputfile, inputfile, BCompare, Script;
       inputfile = inputfilepath;
       outputfile = ConfigurationManager.AppSettings["MFxmlSortFilePath"];
       outputfile = outputfile + System.Guid.NewGuid().ToString() + ".txt";
       BCompare = ConfigurationManager.AppSettings["BCompareExe"];
       Script = ConfigurationManager.AppSettings["Script"];

       Process p = new Process
       {
            StartInfo =
                    {
                        FileName = "\"" + BCompare + "\"",
                        Arguments = " " + "\"" + "@" + Script + "\"" + " " + "\"" + inputfile + "\"" + " " + "\"" + outputfile + "\"  /grant BUILTIN\\Users:IIS_IUSRS"
                    }
                };

       p.Start();
       p.WaitForExit();
       p.Close();
       return outputfile;
}

2 个答案:

答案 0 :(得分:0)

您不能只在网络服务器上运行流程。当然,您可以在开发机器上执行此操作,因为您必须拥有更多权限。

请点击此链接,它必须对您有用。它引导CGI程序注册,权限授予并在启用IIS的Web服务器上运行。

http://blogs.iis.net/thomad/archive/2010/04/04/how-to-run-a-cgi-program-under-iis-7-0-or-iis-7-5.aspx

答案 1 :(得分:0)

我不太确定,但我认为在Stackoverflow上提出了一个类似问题。

如果CGI程序(如Tigran所指出的)不是您的选择(出于任何原因) 你有两个选择:

  1. 默认情况下,您网站的应用程序池仅在有限的权限下运行。将您网站的应用程序池配置为在本地系统帐户下运行。但是,由于安全原因,我不推荐此选项。请按照上面的链接获取有关如何完成此操作的分步指南。
  2. 请勿更改应用程序池的默认设置。而是创建一个Windows服务,它承载一个WCF服务,提供一个服务方法(例如CompareXml)来执行您的控制台应用程序。从您的网站内部调用WCF服务的CompareXml方法。
  3. 希望,这有帮助。