当外部进程从ASP.NET运行时,IIS会话结束

时间:2013-06-18 13:30:03

标签: asp.net session iis

从ASP.NET应用程序运行外部进程时遇到问题。

该过程运行如下:

[WebMethod(EnableSession = true)]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public static WebResult generateSomething(string language)
{
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.UseShellExecute = false;
            psi.RedirectStandardError = true;
            psi.RedirectStandardOutput = true;
            psi.RedirectStandardInput = true;
            psi.WindowStyle = ProcessWindowStyle.Hidden;
            psi.CreateNoWindow = true;
            psi.ErrorDialog = false;
            psi.WorkingDirectory = Environment.CurrentDirectory;
            psi.FileName = String.Format("\"{0}\"", Path.Combine(appDir, Properties.Settings.Default.PATH_TO_APP_TEXT));
            psi.Arguments = arguments.ToString();

            modeller.log.Info("Arguments: " + psi.Arguments);

            var outputText = new StringBuilder();
            int exitCode;

            var result = new WebResult();

            using (Process process = new Process())
            {
                process.StartInfo = psi;
                process.OutputDataReceived += (sendingProcess, args) => { outputText.Append(args.Data); };
                process.ErrorDataReceived += (sendingProcess, args) => { outputText.Append(args.Data); };
                process.Start();
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
                process.WaitForExit();
                exitCode = process.ExitCode;
            }

            string outText = outputText.ToString();

在进程完成(成功与否)之后,该方法立即停止ASP.NET IIS会话结束,因此任何通过cookie的身份验证上下文都会中断。

任何人都可以帮忙解决这个问题吗? 提前致谢

0 个答案:

没有答案