我需要讓我的網站上用戶下載一個文件(XML文件)下載使用MVC文件
我試圖
public FileResult DownloadFile(string fileid)
{
if (!string.IsNullOrEmpty(fileid))
{
byte[] fileBytes = Encoding.ASCII.GetBytes(FileData);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet,FileName + ".bccx");
}
return null;
}
AJAX:
function downloadFile(id) {
$.ajax({
url: sitePath + "Controller/DownloadFile?fileid=" + id,
type: 'post',
asysnc: false
})
.done(function() {
});
}
但沒有什麼是下載
可能重複的[下載由jQuery.Ajax文件](http://stackoverflow.com/questio NS/4545311 /下載一個文件按jQuery的AJAX) – malarzm