Launching new process from ASP.NET

醉酒当歌 提交于 2019-12-25 01:46:43

问题


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\sitedirectory.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/18410314/launching-new-process-from-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!