Firefox & IE: Corrupted data when retrieved from c

2019-05-18 02:55发布

问题:

I have a request to the server which looks like this:

http://localhost/Combine.aspx/flag/file1.js,file2.js,file3.js

I have also tried this:

http://localhost/Combine.aspx/flag/value/file1.js/file2.js/file3.js

It simply combines the three files which it was given: this works fine.

Upon the first request from Firefox, the page displays correctly. When the page is refreshed again, the content looks like this:

��������`I�%&/m�{J�J��t��`$�����iG#)�*��eVe]f@�흼��{���{��;�N'

In that case, no request is made to the server, the file is only retrieved from the firefox cache, as far as I can tell.

If I force-refresh the page with Control-F5, the page looks normal again.

Here is the request and response (in firebug) with Control-F5 (works):

Response

Cache-Control   public
Content-Type    application/javascript; charset=utf-8
Content-Encoding    gzip
Expires Sun, 26 Feb 2012 02:57:26 GMT
Last-Modified   Fri, 07 Jan 2011 21:08:54 GMT
Etag    CLYvZwbFmainWEMi8h-6x-zNEIQ1
Vary    Accept-Encoding
Server  Microsoft-IIS/7.5
Set-Cookie  auth=longstring; path=/
X-AspNet-Version    2.0.50727
X-Powered-By    ASP.NET
Date    Thu, 03 Mar 2011 02:57:26 GMT
Content-Length  918

Request

Host    localhost
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
Cookie  auth=longstring
Pragma  no-cache
Cache-Control   no-cache

Here is the same with just F5 (doesn't work):

Response:

Cache-Control   public
Content-Type    application/javascript; charset=utf-8
Content-Encoding    gzip
Expires Sun, 26 Feb 2012 02:57:26 GMT
Last-Modified   Fri, 07 Jan 2011 21:08:54 GMT
Etag    CLYvZwbFmainWEMi8h-6x-zNEIQ1
Vary    Accept-Encoding
Server  Microsoft-IIS/7.5
X-AspNet-Version    2.0.50727
X-Powered-By    ASP.NET
Date    Thu, 03 Mar 2011 03:01:31 GMT
Content-Length  1533

Request:

Host    localhost
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
Cookie  auth=longstring

The only thing that I can tell is different is the Content-Length (which is likely causing the corruption), but since it never hits the server, I have no control over it.

What could be causing this?

Edit:

This happens on IE8 as well, but instead of viewing a corrupt file, it downloads the corrupt file. No request is ever made to the server (set a breakpoint in visual studio).

As for chrome, when viewing the url directly, a request to the server is made every time, and it works every time. I believe, though, that if it were included in a tag, it would behave similar to Firefox.

Oh, and also:

If I turn off the Expires header (which is one of the flags in the URL), everything works fine.

Edit 2:

I was able to work around this by not sending both an Expires and ETag header, only one or the other. I have no clue why an ETag header would cause such corruption, though.

回答1:

It is because of your IIS configuration. Adjust IIS as ASP 4.0 Classic, not Default Application Pool