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
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.

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

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
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.

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
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