0

Good afternoon, I am new developing on web asp.net, I am running one batch file from my website that I developed with c# Visual Studio. I am using the following code:

private void EjecutarAORA(string strNombreArchivoBatch, int intTiempoDeEspera)
    {
        string strArgumentos = string.Format("\"{0}\" ", strNombreArchivoBatch);
        System.Diagnostics.Process objProcess = new System.Diagnostics.Process();
        objProcess.StartInfo.FileName = "Advisor.exe"; //Path.GetFullPath(bat);
        objProcess.StartInfo.Arguments = strArgumentos;

        //set the rest of the process settings
        objProcess.StartInfo.Verb = "runas";
        objProcess.StartInfo.UseShellExecute = false;
        objProcess.StartInfo.CreateNoWindow = true;
        objProcess.Start();

        objProcess.WaitForExit(intTiempoDeEspera);
        if (objProcess.HasExited == false)
        {
            objProcess.Kill();
        }
    }

This code is working when I ran the code with the Visual Studio debugging, but once I publish the project and I install it on My IIS7 I got an Http request TimeOut. Also I modified the timeout, and I got the same error. Do you know why is working on Debuggin Visual Studio and it do not works on IIS?

Thank you so much

Vlad
  • 33
  • 1
  • 8
  • [check this answer. this is may be same issue](https://stackoverflow.com/a/31755811/1704458) But there could be possibility that your exe executes too long and `ping` on the pool breaks it. Generally, this is not a good idea to do this type of stuff in web applications unless you don't do `WaitForExit`. You should fire and forget. And then possibly check the outcome on a different thread – T.S. May 12 '20 at 18:23
  • https://blog.lextudio.com/web-application-differences-in-visual-studio-and-iis-60fec7e311b3 Learn the differences first. – Lex Li May 12 '20 at 20:51
  • Thank you TS, I avoid the WaitForExit Function and the application works correctly. – Vlad May 12 '20 at 22:48

0 Answers0