开发者

Process worker is not working on IIS 7

Lets take scenario, I developed web application (ASP.NET MVC) which shows list of .xml files and we select two .xml fil开发者_高级运维es for comparison and use a comparing utility like Beyond Compare 3.

Basically, I have Scrapt file (Beyond Compare 3 Script) which runs on System.Diagnostic.Process and generates difference report files against the script. I want to use the script in a process which shows a runtime generated difference report. When I run the application from Visual Studio it runs perfectly and shows the expected difference file, but when I deploy this application on my IIS Webserver then it does not generate the difference file and simply shows input file as the output file.

Following is the method which starts the process and generates the Beyond Compare result file as a output file. But following code is running on Visual Studio Development server but it doesn't work on IIS (website deploy on IIS Server).

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;
}


You can not just run a process on webserver. For sure you are able to do that on your dev machine as there you have to have much more permissions.

Follow this link, it have to be useful to you. It guides through CGI program registration, permission grant and run on IIS enabled web servers.

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


I am not really sure but I think a simialr question was asked on Stackoverflow.

If a CGI program (as Tigran pointed out) is not an option for you (for whichever reason) you have two options:

  1. By default the applicaton pool of your website runs only with limited permission. Configure the application pool of your website to run under the local system account. However I do not recommend this option because of security reasons. Follow the link above for an step by step guide on how to accomplish this.
  2. Do not change the default settings for your application pool. Instead, create a Windows Service which hosts an WCF-Service offering a service method (e.g CompareXml) for executing your console application. From within your website call the WCF-Service's CompareXml method.

Hope, this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜