The reason it's only compressing your ASPX file is that the code you have written is only embedded in the ASPX file. An ASPX file is a separate request from any linked content it contains. So if you have an ASPX page that contains:
<img src="www.example.com\exampleimg.jpg" alt="example" />
This would amount to 2 requests (DNS lookups aside) from your browser to the resources:
- for the aspx page and
- for the image contained by the aspx page.
Each request has it own response steam. The code you have posted is attaching to the ASPX response stream only, which is why only your ASPX page is being compressed. Lines 1 & 2 of your posted code are essentially taking over the normal response stream of the page and injecting some "middle man" code that in this case eats and compresses the normal output stream with a GZip stream and sends that down the wire instead.
Lines 3 & 4 are setting up the response headers. All http requests and responses have headers that are sent prior to the content. These set up the request/response so that the server and client know what is being sent and how.
In this case Line 3 is informing the client browser that the response stream is compressed via gzip and therefore needs to be de-compressed by the client browser prior to display.
And Line 4 is simply turning on the Accept-Encoding header of the response. This would otherwise have been absent from the response.
There are pluggable modules you can write/obtain that allow you to compress a multitide of other MIME type such as *.js and *.css but you're better off just using the built in compression functionality of IIS.
You haven't said which verson of IIS you are using but if it were IIS 7.0, it would require that you include something like the following into the section of you web.config file:
<httpCompression>
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" />