Anyone seen a "Content Encoding Error" with file d

Posted by Community Admin on 04-Aug-2018 00:36

Anyone seen a "Content Encoding Error" with file downloads in Firefox?

All Replies

Posted by Community Admin on 24-Apr-2012 00:00

It seems that PDFs served by Sitefinity are working fine for us via IE, but when viewed with Firefox, we get a "Content Encoding Error" and with Google Chrome, it simply fails to download.

I think it might have to do with server compression or encoding. Any ideas where to start?

Posted by Community Admin on 24-Apr-2012 00:00

Hey Dan,

Have you verified the content-type served? It should be 'application/pdf' (see 1st screenshot).
You can alter it under Administration>settings>Advanced>Libraries>MimeMappings (2nd screenshot).

If it is, you can try changing it to 'application/octet-stream'. This should force the file to be downloaded instead of opened in the default pdf viewer.

---
To verify cache - you could add this just before the </systemConfig> tag in SystemConfig.config
<cacheManagers>
 <add pollWhetherItemsAreExpiredIntervalSeconds="60"
    startScavengingAfterItemCount="1000"
    whenScavengingRemoveItemCount="10"
    CacheStore="InMemory"
    name="Global"
  />
 <add pollWhetherItemsAreExpiredIntervalSeconds="60"
    startScavengingAfterItemCount="1000"
    whenScavengingRemoveItemCount="10"
    CacheStore="InMemory"
    name="ContentOutput"
  />
</cacheManagers>

And add the following to LibrariesConfig.config:
<mimeMappings>
  <add mimeType="application/pdf" fileExtension=".pdf" />
</mimeMappings>

Finally to verify the web.config, by default the caching should read this (just before the </system.webServer> tag:
<staticContent>
  <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="31.00:00:00" />
</staticContent>
<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true" />

On the server, in the IIS Manager, you can check to make sure there are no handlers registered for *.pdf

The compression section will of course reflect the web.config settings, but you might want to verify that the output caching section is empty and that (if you have it installed) IIS Media Services doesn't have  throttling or streaming configurations interfering...

Hope it helps,
Jochem.

Posted by Community Admin on 24-Apr-2012 00:00

That is very helpful. I'll try those changes today.

You've posted on IIS dynamic and static compression in the past. Do you find any issues with compression and PDF or Word documents?

Do you happen to know if this issue could be caused / or is related to forcing SSL encryption on the /sitefinity folder? I only ask, because that's all I did the day before I noticed this PDF issue.

I do not have IIS Media Services installed. (I don't believe - we're not using it, I'll double check that it wasn't enabled by mistake)

Thanks again!

Posted by Community Admin on 24-Apr-2012 00:00

Hey Dan,

No, so far I've not run into any issues with regards to compression and documents (pdf/doc/etc) but I've not tried it with SSL. Easy to verify in your case by just dropping a pdf into the folder and call it with a direct url (would love to hear the results)... 

One other thing I thought you might try out is switching file providers, to see if possibly .pdf's are served differently when retrieved from the db vs file-based and check with Fiddler/Firebug if that's causing a different mime-type to kick-in which may cause the browser viewers to crash...

Jochem.


Posted by Community Admin on 25-Apr-2012 00:00

I wonder if this old issue for Sitefinity 3 + Server 2008 + Google Chrome Browser would be related. We are using Server 2008 and Google Chrome. If Sitefinity 5 uses a similar upload mechanism to Sitefinity 3, it would explain the MIME type issues.

Threads also possibly related:
- PDF Links broke after upgrade to Sitefinity 4.4.2117.0 (mentions PDFs work in IE, but not other browsers)
- PDF file not opening on Mobile (issues opening a PDF on Android, but not other browsers)



Posted by Community Admin on 25-Apr-2012 00:00

The following warning was logged into IIS immediately after I had another failed PDF download with Google Chrome 18 and Sitefinity 5.0.2325. I do not understand what it means, but it might be useful to someone to solve this.

It says there is an "Invalid use of a response filter". Am I causing my own trouble with incorrect server setup, or is this a Sitefinity warning?

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 4/25/2012 10:47:14 AM 
Event time (UTC): 4/25/2012 5:47:14 PM
Event ID: 92049b1491cb4d0a9399f77fe7da5127 
Event sequence: 977
Event occurrence: 5
Event detail code: 0
  
Application information:
    Application domain: **** [OMITTED BY POST AUTHOR] ****
    Trust level: Full
    Application Virtual Path: /
    Application Path: **** [OMITTED BY POST AUTHOR] ****
    Machine name: **** [OMITTED BY POST AUTHOR] ****
  
Process information:
    Process ID: 2992
    Process name: w3wp.exe
    Account name: **** [OMITTED BY POST AUTHOR] ****
  
Exception information:
    Exception type: HttpException
    Exception message: Invalid use of response filter
   at System.Web.HttpResponseStreamFilterSink.VerifyState()
   at System.Web.HttpResponseStreamFilterSink.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.Compression.DeflateStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.IO.Compression.GZipStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr)
   at System.Web.HttpResponse.FilterOutput()
   at System.Web.HttpApplication.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
 
  
  
Request information:
    Request path: /docs/threat-assessment/parent-questionnaire-(spanish).pdf
    User host address: **** [OMITTED BY POST AUTHOR] ****
    User: **** [OMITTED BY POST AUTHOR] ****
    Is authenticated: True
    Authentication Type: Sitefinity
    Thread account name: **** [OMITTED BY POST AUTHOR] ****
  
Thread information:
    Thread ID: 40
    Thread account name: **** [OMITTED BY POST AUTHOR] ****
    Is impersonating: False
    Stack trace:    at System.Web.HttpResponseStreamFilterSink.VerifyState()
   at System.Web.HttpResponseStreamFilterSink.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.Compression.DeflateStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.IO.Compression.GZipStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr)
   at System.Web.HttpResponse.FilterOutput()
   at System.Web.HttpApplication.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

(I will be happy to provide the omitted details if they are deemed necessary to solving this issue.)

Posted by Community Admin on 26-Apr-2012 00:00

I hate to say this, but I think the internal PDF viewer in Google Chrome is part of the problem. It is just not as reliable as the Acrobat plugin used by the other browsers. At least when Firefox has an issue with PDF downloads I get a clear error message. With Google, just the white screen of death. 

I would prefer it to be a server issue to correct because I cannot control all my visitors client browsers, but in the end finding the cause is better than not knowing.

Posted by Community Admin on 26-Apr-2012 00:00

Jochem

I don't have a librariesConfig.config file in my App_Data/Sitefinity/Configuration. The lines you mentioned are currently located in my Web.Config.

Is librariesConfig.config an optional config file? Could I put that code you suggested in my Web.Config?

I currently have the following in web config:

<staticContent>
  <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
  <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="14.00:00:00" />
</staticContent>
<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true" />


Posted by Community Admin on 26-Apr-2012 00:00

This error has taken me everywhere, but I *think* I have it fixed.

After reading this post about Firefox Content Encoding issues with ASP.MVC and RadCompression, I disabled RadCompression it in our web.config and refreshed the server.

...
<system.webServer>
  <!--<add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode" />-->
...

I was still having issues in Firefox, so I re-uploaded the specific file and tested again. It works! Tested a number of other files and in every case, after re-uploading the PDF they worked fine.

So between disabling RadCompression and re-uploading the affected PDFs, it now works correctly on all browsers.

When we have a quiet day, I'll test more thoroughly and post my findings.

Posted by Community Admin on 27-Apr-2012 00:00

Hey Dan,

Glad you managed to solve it and apologies for asking if RadCompression was a good thing to turn on with Sitefinity...

Jochem

Posted by Community Admin on 27-Apr-2012 00:00

Hey, no problem at all. It had been working good for us until we discovered this Firefox PDF encoding issue. 

I have been fairly noisy in the forums about it. Hope it didn't cause anyone trouble - rather I was hoping to document an edge case issue in case I or anyone run into it again.

I am still interested in configuring server compression, as long as we can ensure it works for our static files in all browsers. But we'll be testing that on a non-production server until we get it working.

This thread is closed