从IIS 7.5上部署的asp.net应用程序运行perl脚本

时间:2011-04-28 06:41:15

标签: asp.net perl iis deployment

我有一个非常迫切的要求。我在MVC架构中完成了框架4.0上的ASP.net应用程序。在应用程序中,我调用Perl脚本将数据从MySQL复制到后端的SQL Server 2010。当我从Visual Studio 2010运行应用程序时,Perl脚本成功运行并复制数据。但是当我在IIS 7.5上部署相同的应用程序时,它不显示任何更改或Perl scipt不运行。我尝试打印代码的每一步,发现所有路径都是正确的。 perl脚本将通过批处理文件运行。

以下是启动运行批处理文件的过程的代码,该批处理文件又运行Perl脚本:

string strPath = string.Empty;
string strDirectory = string.Empty;
try {   
    strPath = "/k " + ConfigurationManager.AppSettings["UploadTLInfo"];//Path of the batch file comes from here 
    strDirectory = ConfigurationManager.AppSettings["WorkingDirectory"];
    ProcessStartInfo psi = new ProcessStartInfo("cmd.exe",strPath);
    psi.UseShellExecute = false;
    psi.WorkingDirectory = strDirectory;
    //psi.CreateNoWindow = true;
    //psi.WindowStyle = ProcessWindowStyle.Hidden;
    Process p = new Process();
    p.StartInfo = psi;
    p.Start();                
} catch (Exception ex) {
    throw ex;
}

1 个答案:

答案 0 :(得分:0)

最有可能的是,您的问题与用户权限有关 - 当您从VS运行时,您可能正在使用ASP.NET Dev服务器并且它使用当前用户的凭据,而当您从IIS运行时,它将使用NETWORK_SERVICE(或类似的系统用户)可能具有导致该问题的有限权限。另一个(但不太可能)问题可能是批处理文件和/或珍珠可能依赖于某些未在机器级别定义的环境变量等。

其中一个解决方案是运行模拟具有特定权限和/或环境(see this to run process as another user)的其他用户的流程。