asp.net-mvc 将 excel 文件保存到特定位置

asp.net-mvc save excel file to specific location

我有以下代码可以将文件下载到客户端的机器上,效果很好。但是,我还需要在下载开始之前询问用户他们想将文件保存在哪里。

这是我在操作方法中做的事情(下面代码中的某个人)还是客户端必须在 his/her 浏览器上设置的选项并且独立于我的代码做什么?

System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;

response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ";");
response.TransmitFile(filePath + fileName);
response.Flush();

response.End();

是的,"this an option the client has to set on his/her browser and independent of what my code does"。

据我所知,这是浏览器的 responsibility/behavior。如果你想要更多的客户端控制,你将不得不编写一个客户端应用程序来保存到特定位置,或者(更容易)让最终用户配置他们的浏览器以询问将下载保存到哪里。