C# 使用ASP.NET MVC打开Word/Excel文件#

C# 使用ASP.NET MVC打开Word/Excel文件#,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,我有一个带有按钮的视图,当单击该按钮时,我使用Microsoft word打开word文件: JS //CLICK EVENT $('.openDocument').click(function () { $.ajax({ url: "openFile", method: "GET", async: false, success: function (respuesta) {

我有一个带有
按钮的
视图
,当单击该
按钮时,我使用
Microsoft word
打开word文件:

JS

//CLICK EVENT
$('.openDocument').click(function () {
        $.ajax({
            url: "openFile",
            method: "GET",
            async: false,
            success: function (respuesta) {

            }
        });

    });
控制器

 [HttpGet]
   public void openFile()
   {
      Process.Start(@"C:\Users\user01\Downloads\Test_document.docx");
   }
关于这一点,我有两个问题:

1) 当我在本地发布项目时,我无法再次打开该文件(仅当我运行它时),为什么在发布时它不会打开?(任务管理器中仅显示Microsoft Word图标)

2) 已发布,如何才能让另一台电脑打开文件(显示在另一台电脑上),而不是在服务器电脑上打开


Thanx

试着用这个来回答问题1

public static Process CreateProcess(string exePath, string arguments = null, bool isHidden = true, string workingDirectory = null)
        {
            ProcessStartInfo processStartInfo = new ProcessStartInfo
            {
                FileName = exePath,
                Arguments = arguments,
                UseShellExecute = false,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                WorkingDirectory = workingDirectory ?? Path.GetDirectoryName(exePath)
            };

            if (isHidden)
                processStartInfo.CreateNoWindow = true;

            return new Process()
            {
                StartInfo = processStartInfo,
                EnableRaisingEvents = true
            };
        }

        public static void RunProcess(string exePath, string arguments = null, bool isHidden = true, string workingDirectory = null)
        {
            Process process = CreateProcess(exePath, arguments, isHidden, workingDirectory);
            if (process.Start())
            {
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
                process.WaitForExit();
            }


        }