This is a migrated thread and some comments may be shown as answers.

RadGrid PDF export filename and extension wrong

6 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 05 May 2015, 12:04 PM

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.

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 May 2015, 02:32 PM
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.

 
0
Michael
Top achievements
Rank 2
answered on 07 May 2015, 08:53 AM

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

0
Michael
Top achievements
Rank 2
answered on 11 May 2015, 06:53 AM

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

0
Daniel
Telerik team
answered on 12 May 2015, 11:00 AM
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.

 
0
Michael
Top achievements
Rank 2
answered on 13 May 2015, 06:29 AM

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

0
Accepted
Daniel
Telerik team
answered on 13 May 2015, 11:05 AM
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
Tags
Grid
Asked by
Michael
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Michael
Top achievements
Rank 2
Share this question
or