Hy i have a rad grid, which im using a RadMenu as a context menu with it. All works fine.
The Radmenu Command calls the method "OpenFile(int id)" in the code behind file to as u correctly guess should opens a already on the server stored file in a file stream to the client.
Heres the method:
After i reach the Reespnse.End(); line i get following exception:
((System.Threading.ThreadAbortException)(ex)):
{Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}
Is there any propertie i have to set to be able to give my user the file / filestream ?
Or what can i do to make it work properly?
thx mario
The Radmenu Command calls the method "OpenFile(int id)" in the code behind file to as u correctly guess should opens a already on the server stored file in a file stream to the client.
Heres the method:
private void OpenFile(int id) |
{ |
try |
{ |
Document doc = BLDocument.GetDocument(id); |
if (File.Exists(doc.Metainformation.filepath)) |
{ |
// Create New instance of FileInfo class to get the properties of the file being downloaded |
FileInfo file = new FileInfo(doc.Metainformation.filepath); |
// Clear the content of the response |
Response.ClearContent(); |
// LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header |
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); |
// Add the file size into the response header |
Response.AddHeader("Content-Length", file.Length.ToString()); |
// Set the ContentType |
Response.ContentType = ReturnExtension(file.Extension.ToLower()); |
// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead) |
Response.TransmitFile(file.FullName); |
// End the response |
Response.End(); |
} |
} |
catch (Exception ex) |
{ |
} |
} |
After i reach the Reespnse.End(); line i get following exception:
((System.Threading.ThreadAbortException)(ex)):
{Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}
Is there any propertie i have to set to be able to give my user the file / filestream ?
Or what can i do to make it work properly?
thx mario