I figured out that I can set Content-Disposition using the urlrewrite module using the following configuration:
<outboundRules> <rule name="Set content disposition on pdfs" preCondition="FileIsPDF"> <match serverVariable="RESPONSE_Content-Disposition" pattern=".*" /> <conditions> <add input="{REQUEST_FILENAME}" pattern="(.*)\\([^/]+)\.pdf$" /> </conditions> <action type="Rewrite" value="inline; filename="{C:2}.PDF"" /> </rule> <preConditions> <preCondition name="FileIsPDF"> <add input="{REQUEST_FILENAME}" pattern="\.pdf$" /> </preCondition> </preConditions> </outboundRules>
That didn't solve the problem though.
Check that you don't have firewall that strips the response headers. That happened to me once and was not funny at all :)
Nope, Fiddler tells me that the header is there.
When I link a media file page I return with a FileStreamResult, I wonder how EPi returns the file?
Problem solved.
As I was trying this on a test website that was auth-locked you needed to login to download the file.
The android browser was of course logged in but when you tried to open (download) the file with Adobe you would get denied.
So no headers or any special treatment necessary, just make sure the file is accessible for the Everyone group.
Hello
When linking to media in a XhtmlText field, in this case a pdf file, it works fine on all platforms except for Android.
What happens on Android is that when you choose to open the file in Adobe you get the following error:
This happens because the file is never downloaded.
If you, instead of choosing to open the file with adobe, choose to open it with the browser it will download fine and you can open it from your downloads folder.
I can workaround this by creating a mediafile pagetype with it's own controller.
In that controller I can set the Content-Disposition header which seem to fix the issue.
But editors still can, and therefore will, put links to mediafiles in the text.
Is there any event or something I can override to set Content-Disposition header when a file in globalassets is requested?
Any other suggestions?