not on top of call stack ?!

3 posts, 0 answers
  1. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 12 Aug 2009 Link to this post

    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:

    private void OpenFile(int id) 
                    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 
                        // 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) 
                        // End the response 
                catch (Exception ex) 

    After i reach the Reespnse.End(); line i get following exception:


    {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
  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 12 Aug 2009 Link to this post

    Hi Mario,

    Response.End() always triggers the ThreadAbortException. You can check this page for additional info.

    All the best,
    Atanas Korchev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 13 Aug 2009 Link to this post

    I had enabled (added) the Context Menu (im using with my radgrid) with Ajax which runs a thread and so it has a problem ending the thread.

    When i dont add the calling button control to ajaxmanager it works.


    Also read that some people have problems debugging it with their Visual Studio, when they Resonse.End in a try catch block, but thats only a problem with a wrongly configured Visual Studio.

    thx Mario

Back to Top