For work I am working on a file export. The data all exports just fine but what is concerning is that no file dialog appears, as well there is no indication from the browser that the file has been downloaded.
My button has an onclick event, this calls
baseDir = ProjectConfig.BaseShareFolderPath
Dim fileStream As FileStream = New FileStream((baseDir + "\" + filePath), FileMode.Open, FileAccess.Read)
Dim bytes As Byte()
Dim binaryReader As BinaryReader = New BinaryReader(fileStream)
bytes = binaryReader.ReadBytes(fileStream.Length)
Dim fileName As String = filePath.Substring(filePath.IndexOf("\Crm") + 1)
context.Response.ContentType = "xls"
context.Response.AppendHeader("content-disposition", "attachment;filename=" & fileName)
context.Response.OutputStream.Write(bytes, 0, bytes.Length)
Files cannot be downloaded to the client machine using ajax.
window.open(downloadUrl). The latter will open a new window to download the file, the first will use the current window to perform the download.
For reference: Download a file by jQuery.Ajax