我正在 MVC5 中开发一个如下所示的视图:

我需要选择表的一个或多个记录,并能够在数据库中下载以前保存的文件。我一直在寻找解决方案并进行了多次测试,但我找不到解决方案。我试图从 javascript 将选定的代码发送到控制器并从中下载文档,但我无法做到。下载可能是在您可以的情况下,获取所有文件并生成一个 zip,或者自动将所有文件下载到浏览器的默认文件夹。我将不胜感激任何可以帮助我的人......您好!
这是我的 ajax 调用:
$.ajax({
type: "POST",
url: "/GestionGarantias/Garantias/Download",
data: { pCodigo: mCodigo },//Here I would send the list of //codes, but now to test, I only call the controller regardless of the value, //because the values in the list set them in the handy controller to test.
xhrFields: {
responseType: 'blob'
},
success: function (data) { //Here should I bring a zip with all files supposedly?
var a = document.createElement('a');
var url = …Run Code Online (Sandbox Code Playgroud)