3

We updated a time before our ASP.NET legacy web application to use .NET Framework 4.0. No any problems there. Last sprint, we implemented new module to rewrite SEO optimized URLs. But, because we want use URLs without any file and extension (for example instead of http://server/Some-Nice-URL/file.aspx only http://server/Some-Nice-URL/) we were forced to set 'runAllManagedModulesForAllRequests' to 'true', because without this was the ASP.NET session not available.

We have now the problem with static compression and GZIP. After couple of postbacks we "lost" the CSS and/or Javascripts. If I access the CSS or Javascript file directly, I get sometimes browser message 'Content Encoding Error', sometimes is the file delivered correctly. In Fiddler is length of CSS or Javascript files sometime incorrect but the in HTTPCompression is shown GZIP Encoding and "Response is encoded and my need to be decoded before inspection". After click "The magic number in GZip header is not correct". If we set 'runAllManagedModulesForAllRequests' or 'doStaticCompression' to 'false', no any problems with static compression and "lost" CSS and/or Javascript files.

Any idea?

Anton Kalcik
  • 2,107
  • 1
  • 25
  • 43
  • Check the order of all your modules. Thank about where your module installs in the order and how it might affect the others. – Kevin P. Rice Jan 25 '12 at 07:08

1 Answers1

3

This is happens because in some point you set the content length of your files on header, after that the gzip try to change that length but fail because you do not have set up the iis to be able to change the headers, and you send gzip file with wrong size and this creates problems.

To solve this, find the point that you set this content length and remove it, or change the iss to accept header change after you have set it.

Look and this similar answer: https://stackoverflow.com/a/3210574/159270

and this : ASP.NET site sometimes freezing up and/or showing odd text at top of the page while loading, on load balanced servers

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • not the complete solution but i figured out with your references. Thanks!! – Megawolt Feb 08 '12 at 12:02
  • @Megawolt Well I can not give you complete solution because actually you need to locate on your source code where you set the content-length. Probably some of your modules do that. Its a nasty issue here and have to do with the server headers. – Aristos Feb 08 '12 at 13:08
  • Yep you're right. At the otherhand, problem just seen to besolved. But I can receive same error in random pages with previously correctly handled resources :(. Do you have any advice for that? – Megawolt Feb 09 '12 at 11:25
  • @Megawolt Maybe something stay on cache ? the iis have cache for static pages, the browser have cache... can you identify the problem ? is on headers or somewhere else ? can you disable the gzip to see if its working ? can you check if there is gzip conflict with iis and asp.net gzip ? – Aristos Feb 09 '12 at 11:43
  • There is a ".css". When I debug solution work like a charm. But not depend on a time or page or click count, same ".css" file throws Encoding Error. IIS has gzip encoding on static files.My code looks for gzip or deflate for encoding and set header for that... There is no-cache in meta tags... I feel like desperate housewife :D – Megawolt Feb 09 '12 at 11:58
  • @Megawolt The css is NOT pass from asp.net - make sure that is not pass and not set again gzip headers !!! IIS cache the static compression, maybe there is an error. Disable iis cache it to check it out. Desperate housewifes is a myth ! they make xxx all day, where is the desperate on that ? :))) – Aristos Feb 09 '12 at 12:01
  • Sorry I have forgot to say. I have a wildcard for handle for all files. But that's not the problem. If they can't pass through .net i can't change my Css Dynmaically. I can do it now bur i'm receiving error sometimes... I feel like because, I have a problem, my friends helping me but I am trully XXX'd :D – Megawolt Feb 09 '12 at 12:45
  • @Megawolt If you handle all files, then the css pass from global.asax and get again addition headers for compression. Debug this on global asax to find it out and stop css from extra compression ! – Aristos Feb 09 '12 at 12:53