【发布时间】:2019-04-15 09:35:13
【问题描述】:
我需要向客户端发送文件以使用 javscript 下载,我找到了以下方法:
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename="myflie.txt");
Response.ContentType = "text/plain";
Response.Flush();
Response.TransmitFile(filePath);
Response.End();
但是我无法获取文件名,因为这似乎返回了一个原始文件并且调用 getResponseHeader 不起作用。我也无法下载文件本身,因为有一个错误Resource 'blob: …' not allowed to load。此外,除了文件名之外,我还想将其他一些参数作为 JSON 传递,但我无法使用这种方法来做到这一点。我是 asp.net 的初学者,所以我希望我足够清楚。
【问题讨论】:
标签: c# asp.net asp.net-mvc-4