Executing C ++. Exe from IIS to asp.net using ProcessStartInfo

I am executing Simple C ++ (.exe) from a web service in C #. It works fine in a development environment (in Visual Studio), but when I hosted in IIS, its process won't start. I tried using Simple C # Console Application, it works great for me. I have already given permission for

  • All
  • IUSR
  • Local Service
  • Network service
  • Net
  • IIS_Users

from IIS using edit rights.

[WebMethod]
    public string GETOCR()
    { 
        string OCROutput ="";
        ProcessStartInfo startinfo = new ProcessStartInfo("C:\\BSG\\ProcessOCR.exe", "12,13;964,15;964,634;9,634 \"C:\\BSG\\20150709_224156.jpg\" ");
        startinfo.CreateNoWindow = true;
        startinfo.UseShellExecute = false;
        startinfo.RedirectStandardOutput = true;
        startinfo.WindowStyle = ProcessWindowStyle.Normal;
        try
        {
            using (Process exeProcess = Process.Start(startinfo))
            {
                OCROutput = exeProcess.StandardOutput.ReadToEnd();
                //Response.Write(OCROutput);



                exeProcess.WaitForExit();
            }

        }
        catch (Exception)
        {

            throw;
        }

        return OCROutput;
    }

      

+3


source to share


1 answer


You need to check your site's application pool account. To do this, click on your site in IIS (valid for IIS 7 and above), then click Basic Settings in the Actions pane on the right. You will see the name of the application pool, remember it and click "Cancel". After that go to Application Pools , find the application pool you remember and select it. Click Advanced Settings ... in the Edit Application Pool pane on the right. Find Identity under Process Model . The id value is the account for which you need to set permission in the Security tab for the fileC: \ BSG \ ProcessOCR.exe (not for the site folder!) And where this program will write / read files to / from (if any).



enter image description here

0


source







All Articles