public FilePathResult DownLoadFileFromPath(string DateNmae)
{
string name = DateNmae;
string virtualPath = "~/Temp/" + name;
string physicsPath = Server.MapPath(virtualPath);
return File(physicsPath, "application/octet-stream", name);
}
///文件下载
function GetFileData(obj) {
var DataNameStr = $(obj).attr("name");
var DataName = new Array(); //定义一数组
DataName = DataNameStr.split(","); //字符分割
for (var i = 0; i < DataName.length; i++) {
alert(DataName[i]);
GetFileDataFun(DataName[i]);
}
}
///文件下载
function GetFileDataFun(data) {
$.ajax({
type: "post",
url: "/ConferenceDataManagement/DownLoadFileFromPath",
data: { "DateNmae": data },
success: function (result) {
window.location = "/ConferenceDataManagement/DownLoadFileFromPath?DateNmae=" + data;
}
});
}
500错误,IIS没有开放这个文件的下载权限。开放一下就可以了。
谢谢大佬