Help engineers, I try to download a file that is a Base 64 string; This can be a pdf or image, the case here is that when you want to download the file; in the browser I get the following error
Uncaught TypeError: Can not read property 'PRM_ParserErrorDetails' of undefined at Sys.WebForms.PageRequestManager._parseDelta (MsAjaxJs? v = c42ygB2U07n37m_Sfa8ZbLGVu4Rr2gsBo7MvUEnJeZ81: 1) at Sys.WebForms.PageRequestManager._onFormSubmitCompleted (MsAjaxJs? v = c42ygB2U07n37m_Sfa8ZbLGVu4Rr2gsBo7MvUEnJeZ81: 1) at Array. (MsAjaxJs? V = c42ygB2U07n37m_Sfa8ZbLGVu4Rr2gsBo7MvUEnJeZ81: 1) at MsAjaxJs? v = c42ygB2U07n37m_Sfa8ZbLGVu4Rr2gsBo7MvUEnJeZ81: 1 at Sys.Net.WebRequest.completed (MsAjaxJs? v = c42ygB2U07n37m_Sfa8ZbLGVu4Rr2gsBo7MvUEnJeZ81: 1) at XMLHttpRequest._onReadyStateChange (MsAjaxJs? v = c42ygB2U07n37m_Sfa8ZbLGVu4Rr2gsBo7MvUEnJeZ81: 1)
on the side of the aspx I have the following code
<div class="modal-header " style="align-content: center;">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h4 class="modal-title">
<asp:Label ID="lblTitleModal" ClientIDMode="Static" runat="server">
INFORMACION DE LA VENTA
</asp:Label>
</h4>
</div>
<div class="modal-body rowsSpaced" style="-ms-align-content: center; -webkit-align-content: center; align-content: center;">
<div class="form-horizontal">
<div class="form-group">
<div class="row">
<asp:Label ID="lblUsuario" runat="server" Text="USUARIO RESPONSABLE:" CssClass="col-md-3 control-label" AssociatedControlID="txtUsuario"></asp:Label>
<div class="col-md-3">
<asp:TextBox ID="txtUsuario" runat="server" Style="text-align: center" CssClass="form-control" ReadOnly="True"></asp:TextBox>
</div>
<asp:Label ID="lblFecha" runat="server" Text="FECHA VENTA:" CssClass="col-md-2 control-label" AssociatedControlID="txtFecha"></asp:Label>
<div class="col-md-3">
<asp:TextBox ID="txtFecha" runat="server" Style="text-align: center" CssClass="form-control" ReadOnly="True"></asp:TextBox>
</div>
</div>
</div>
<div class="form-group">
<asp:UpdatePanel ID="upModal" ClientIDMode="Static" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<div class="col-md-4" style="text-align: center;" align="center">
<h4>PAGOS DE LA VENTA</h4>
<asp:RadioButtonList ID="rblLista" ClientIDMode="Static" runat="server">
</asp:RadioButtonList>
</div>
<div class="col-md-4">
<h4>CARGA DE ARCHIVOS</h4>
<ajaxToolkit:AsyncFileUpload ID="afuArchivoPago" runat="server" ClientIDMode="Static" OnClientUploadStarted="ArchivoUpload" OnClientUploadError="UploadError" OnUploadedComplete="AsyncFileUpload_UploadedComplete" />
<br />
<asp:LinkButton ID="lbArchivoPago" runat="server" ClientIDMode="Static" CssClass="btn btn-primary" Text="GUARDAR PAGO" OnClick="lbArchivoPago_Click"></asp:LinkButton>
</div>
<div class="col-md-4" style="vertical-align: middle">
<h4>DESCARGA DE ARCHIVOS</h4>
<asp:LinkButton ID="lbDescargarArchivo" runat="server" ClientIDMode="Static" CssClass="btn btn-success" Text="DESCARGAR PAGO" OnClick="lbDescargarArchivo_Click"></asp:LinkButton>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Cerrar</button>
</div>
</div>
</div>
</div>
on the server side is this code
protected void lbDownloadClick_File (object sender, EventArgs e) {
string Name = null; string Extension = null; byte [] File = null; string Selected = rblLista.SelectedValue; string Base64 = null; string ctype = null;
using (Data.DatosDataContext db = new Data.DatosDataContext())
{
Data.Dat_PagosVenta Pago = db.Dat_PagosVenta.FirstOrDefault(p => p.Id == Convert.ToInt32(Seleccionado));
Base64 = Pago.Valor;
Archivo = Convert.FromBase64String(Base64);
Nombre = Pago.Descripcion;
Extencion = Pago.Extencion;
ctype = Pago.ContentType;
}
Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment; filename=" + Nombre + "." + Extencion + "");
Response.ContentType = ctype;
Response.ContentType = "application/octet-stream";
//Response.Cache.SetCacheability(HttpCacheability.NoCache);
//Response.AddHeader("Content-Length", Convert.ToString(Archivo.Length));
Response.OutputStream.Write(Archivo, 0, Archivo.Length);
//Response.BinaryWrite(Archivo);
Response.Flush();
//Response.End();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
I hope you can help me