ITPeterBlackTT
New Member
I get this error when I try and send a file from my asp.net page :Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.My code :// this gets triggered by a \[code\]linkButton\[/code\] on a grid\[code\] protected void Download(object sender, EventArgs e) { LinkButton lb = sender as LinkButton; // save file to temp Byte[] fileBytes = null; using (var db = new DbContext()) { var id = Convert.ToInt32(lb.CommandArgument); fileBytes = db.Requests.Single(x => x.Id == id).File; } var filePath = Path.GetTempFileName(); File.WriteAllBytes(filePath, fileBytes); // send FileInfo fi = new FileInfo(filePath); SendFile(fi); } private void SendFile(FileInfo file) { Response.ContentType = "application/zip"; Response.WriteFile(file.FullName); Response.End();// I also tried the code below I get the same error. //Response.Clear(); //Response.ClearHeaders(); //Response.ClearContent(); //Response.AddHeader("Content-Disposition", "attachment; filename=PriceFile.zip"); //Response.AddHeader("Content-Length", file.Length.ToString()); //Response.ContentType = "application/zip"; //Response.Flush(); //Response.TransmitFile(file.FullName); //Response.End(); }\[/code\]