简体   繁体   中英

Launching new process from ASP.NET

I'm having a very hard time with some C# / ASP.NET (.Net 4) code that works just fine in my development environment, but just isn't working on the production server.

Part of the code attempts to launch a new process to run lame.exe (to convert a .WAV file to .MP3):

Process convert = new Process
     {
       StartInfo =
       {
        FileName = AppDomain.CurrentDomain.BaseDirectory + "bin\\lame.exe",
        Arguments =  "--quiet -q 5 -b 16 \"" + filePath + "\" " + directory + "\\" +                                                        tempfile,
        UseShellExecute = false,
        RedirectStandardInput = true,
        RedirectStandardOutput = true
       }
     };

 convert.Start();
 convert.WaitForExit();

And this works fine on my Windows 7 development PC. However, on the production Windows 2008R2 server, it doesn't do anything: it doesn't crash, or throw any exceptions, just doesn't do anything.

I realise this is almost certainly caused by user permissions, but I'm struggling to fix the issue. Having read dozens of articles, some of which contradict each other, I can't figure out what to do.

All the application needs to do is run lame.exe from the inetpub\\site\\bin directory and spit out a file from one directory to another. I'm fairly sure that lame.exe isn't even starting: having redirected StandardOutput to a StreamReader, I don't see anything being output. And again, no exceptions, or errors, are apparently generated.

The application is running in it's own App Pool, under the "ApplicationPoolIdentity". The W3 Publishing Service is running under Local System, and I've tried ticking the "Allow Service to interact with desktop".

I've even given (temporary) full access rights for the Network Service account to the whole \\inetpub\\site directory.

Does anyone know of a ''definitive'' way of getting ASP.NET under IIS7.5 to create a new process, and what credentials and/or rights do I need to use? Is there any easy way to see IF my external process is being started, so I can narrow down where the apparent lack of permissions is biting me?

What John Saunders says about not creating process inside an asp.net thread! I would recommend just having a 2nd process running on the server that follows the source directory and converts the files in the background, but I see you are attempting to wait for the result. This is also a bad idea as it would halt the processing thread until it completes -- this also does not belong on a production server don't use long-running tasks that way, you kill scalability.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM