I am trying to download files from the server, in this case (EXCEL, JSON AND XML) these files are generated on the server side with Visual Basic, and when generating them, on the client side, it receives the url where the file is located. created, to be later downloaded.
On the client I'm working with JQuery and logic with JavaScript, and I have the following code to perform the download:
// http://localhost:7910/.\/Documentos\/ExportarReporte\/EstadisticasProgramacion.xml
var rutaCompleta = servidorWebApi + ruta;
var save = document.createElement('a');
save.href = rutaCompleta;
save.target = '_blank';
save.download = "EstadisticasProgramacion" || 'unknown';
var evt = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': false
});
save.dispatchEvent(evt);
(window.URL || window.webkitURL).revokeObjectURL(save.href);
but I have two details:
1.- This function does not work for me in Internet Explorer in version 11 (Opera and Chrome work perfectly), and has to do directly with MouseEvent
, and I would like to know what is the best way to download from the Internet Explorer.
2.-In chrome and opera; the xml and excel files download without any problem; but files of type json can not find them and basically all three types of files are in the same folder:
and that type of files is generated through the following Visual Basic code:
Private Shared Function CrearJSONProgramacionEncuestas(ByVal encuesta As ENCUESTA, ByVal nombreArchivo As String)
Using archivo As StreamWriter = File.CreateText(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings("RutaArchivosEncuesta") & "\ExportarReporte\" & nombreArchivo))
Dim jsonSerialize As New JsonSerializer()
jsonSerialize.Serialize(archivo, encuesta)
End Using
Dim urlDocumento As String = ConfigurationManager.AppSettings("RutaArchivosEncuesta").Replace("~"c, "."c).Replace("/", "\/") & "\/ExportarReporte" & "\/" & nombreArchivo
Return urlDocumento
End Function
If someone could help me in those two details ... please.
Error in browser search from the browser: