Hi,
Using the grid ItemCommand I'm trying to "push" a file to the client by doing the following:
This works fine outside the context of a Radgrid. Im a receiving this error:
It seems like it doesn't like that the response headers are modified to push the file to the client with a "save prompt", but this is working everywhere except from a radgrid?
Any clue?
Using the grid ItemCommand I'm trying to "push" a file to the client by doing the following:
| // FileInfo object creation |
| System.IO.FileInfo targetFile = new System.IO.FileInfo(filePath); |
| // clear the current output content from the buffer |
| HttpContext.Current.Response.Clear(); |
| // add the header that specifies the default filename for |
| // the Download/SaveAs dialog |
| HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + targetFile.Name); |
| // add the header that specifies the file size, so that the browser |
| // can show the download progress |
| HttpContext.Current.Response.AddHeader("Content-Length", targetFile.Length.ToString()); |
| // specify that the response is a stream that cannot be read by the |
| // client and must be downloaded |
| HttpContext.Current.Response.ContentType = GetFileType(targetFile.FullName.ToLower().Substring(targetFile.FullName.Length - 4)); |
| // send the file stream to the client |
| HttpContext.Current.Response.WriteFile(targetFile.FullName); |
| // stop the execution of this page |
| HttpContext.Current.Response.End(); |
This works fine outside the context of a Radgrid. Im a receiving this error:
| Error: [Exception... "'Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. |
| Details: Error parsing near '%PDF-1.6 |
| %ýýýý |
| 9 0 '.' when calling method: [nsIOnReadyStateChangeHandler::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "<unknown>" data: no] |
It seems like it doesn't like that the response headers are modified to push the file to the client with a "save prompt", but this is working everywhere except from a radgrid?
Any clue?
