RadGrid PDF export filename and extension wrong

7 posts, 1 answers
  1. Michael
    Michael avatar
    26 posts
    Member since:
    Dec 2010

    Posted 05 May 2015 Link to this post

    Hello.

    I am using Telerik ASP.NET AJAX RadGrid 2010.3.1215.40 in an ASP.NET WebForms application and have the following problem: When I hit the export button of the grid the generated PDF file is displayed with the wrong filename and extension to the user.

    The correct filename would be "my-product-list.pdf".

    But the filename used is "index.aspx" (the name of the ASP.NET WebForms page).

    These are the export settings used on the page:

    <ExportSettings ExportOnlyData="true" OpenInNewWindow="true" IgnorePaging="true" FileName="my-product-list">
        <Pdf PaperSize="A4" AllowPrinting="true" />
    </ExportSettings>

    For some strange reason the problem only happens on our production server. Just like in this case: http://stackoverflow.com/questions/30050996/asp-net-content-disposition-using-wrong-filename-on-production-server (also posted by me)

    Could you please help me to find out what causes this behaviour? I am out of ideas.

  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 06 May 2015 Link to this post

    Hello Krisztian,

    First, I would try whether the problem is reproducible in another browser. Next possible reasons may include SSL/HTTPS, compression (RadCompression, IIS compression, etc) and double ajaxification or a random combination of the above factors.

    Regards,
    Daniel
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. Michael
    Michael avatar
    26 posts
    Member since:
    Dec 2010

    Posted 07 May 2015 in reply to Daniel Link to this post

    Hi Daniel,

    the problem is reproducible in all browsers I've tried: IE, Firefox and Chrome. I deactivated SSL and IIS compression (static & dynamic) with no result. The other things you mention are not used on the page. It seems to me that this is an IIS issue. Are you familiar with any other settings that could be causing this?

    Kind regards,

    Krisztián

  4. Michael
    Michael avatar
    26 posts
    Member since:
    Dec 2010

    Posted 11 May 2015 in reply to Daniel Link to this post

    Hi Daniel,

    is it possible to specify the content-type the RadGrid is using in the HTTP response header? The problem is gone if the content-type is set to "application/octet-stream" instead of "application/pdf". This is so weird.

    Kind regards,

    Krisztian

  5. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 12 May 2015 Link to this post

    Hello Krisztian,

    You can set the content type on GridExporting as shown below:

    protected void RadGrid1_GridExporting(object sender, GridExportingArgs e)
    {
        Response.ContentType = "...";
    }

    I hope this helps.

    Regards,
    Daniel
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. Michael
    Michael avatar
    26 posts
    Member since:
    Dec 2010

    Posted 13 May 2015 in reply to Daniel Link to this post

    Hi Daniel,

    thank you for the solution. Luckily I found the cause of the problem. It was a misconfiguration of the parent website the application is located in.

    The problem was that because of an IIS 7.5 issue someone added the following lines to the web.config file of the website:

    <outboundRules>
        <rule name="Force pdfs to download" preCondition="only match pdfs">
            <match serverVariable="RESPONSE_Content_Disposition" pattern="(.*) />
            <action type="Rewrite" value="attachment" />
        </rule>
        <preConditions>
            <preCondition name="only match pdfs">
                <add input="{RESPONSE_CONTENT_TYPE}" pattern="^application/pdf" />
            </preCondition>
        </preConditions>
    </outboundRules>

    We are going to install the Hotfix (see link above) provided by Microsoft and remove these lines from the web.config file.

    Kind regards,

    Krisztian

  7. Answer
    Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 13 May 2015 Link to this post

    Hello Krisztian,

    I appreciate your taking the time to share the problem in details. I'm sure this will be helpful for the community.

    Regards,
    Daniel
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top