【问题标题】:Why does external process in ASP.NET application fail?为什么 ASP.NET 应用程序中的外部进程失败?
【发布时间】:2012-12-12 15:51:18
【问题描述】:

我有一些代码在 ASP.NET 应用程序中运行,该应用程序运行命令行进程,该进程使用 PSCP.EXE (Putty) 将文件从外部 Linux 服务器复制到本地服务器。当我在 Visual Studio 2010 中使用 Run 命令以交互方式运行 ASP.NET 应用程序时,它运行良好。但是,当我将应用程序部署到 IIS(在同一台服务器上!)并尝试运行它时,我从 PSCP.EXE 命令行返回一个错误。错误是这样的:

致命:网络错误:连接超时

我对 PSCP.EXE 错误做了一些研究,我发现的唯一一件事是人们建议需要指定端口。但我认为这不适用于我,因为当我通过 Visual Studio 运行应用程序时它可以正常工作。

有谁知道为什么在我的机器上从 IIS 7 运行命令时会出现连接超时错误,但是当我在同一个机器上通过 Visual Studio 运行它时它工作正常?

这是我的代码:

string _pscpExePath = ConfigurationManager.AppSettings["PSCPExePath"];
string _localOptionsFolder = ConfigurationManager.AppSettings["LocalOptionsFileFolder"];
string _remoteOptionsLocation = ConfigurationManager.AppSettings["RemoteOptionsFileLocation"];

ProcessStartInfo _procStartInfo = new ProcessStartInfo("cmd", "/c " + _pscpExePath + " -pw " + App.ConfigData.ModemAdminPassword + " root@" + App.ConfigData.ModemIPAddress + ":" + _remoteOptionsLocation + " " + _localOptionsFolder);
_procStartInfo.RedirectStandardOutput = true;
_procStartInfo.RedirectStandardError = true;
_procStartInfo.UseShellExecute = false;
_procStartInfo.CreateNoWindow = true;

using (Process _proc = Process.Start(_procStartInfo))
{
  using (StreamReader _reader = _proc.StandardOutput)
  {
    string _result = _reader.ReadToEnd();
    log.Info("Get Options File Result = " + _result);
  }

  using (StreamReader _error = _proc.StandardError)
  {
    string _result = _error.ReadToEnd();
    log.Info("Get Options File Error = " + _result);
  }
}

【问题讨论】:

    标签: asp.net putty


    【解决方案1】:

    看来我弄错了。 IIS 站点无法连接到 linux 服务器还有一个不同的原因。现在一切正常。这个问题可以标记为已回答,甚至可以删除,因为它确实不是代码或任何问题的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-10
      • 1970-01-01
      • 1970-01-01
      • 2014-07-05
      • 1970-01-01
      • 2010-12-15
      • 2016-08-24
      相关资源
      最近更新 更多