2

i tried to enable SVGZ in iis but I am running into some trouble. This is what I did: I added a svgz mime type to the iis console and compiled a dll to handle the decompression, that I added to the "ISAPI Filter" console:

namespace svgzHandler
    {
        using System;
        using System.Web;    
        public class svgzHandler : IHttpHandler
        {
            public bool IsReusable { get { return true; } }

            public void ProcessRequest(HttpContext context)
            {
                HttpResponse r = context.Response;
                r.ContentType = "image/svg+xml";
                r.AppendHeader("Content-Encoding", "gzip");
                r.WriteFile(context.Request.PhysicalPath);
            }
        }
    }

But it still does not seem to work... Is there any error in this code? is there anything I forgot?

this is the error I get in the browser:

This page contains the following errors:

error on line 1 at column 1: Encoding error
Below is a rendering of the page up to the first error.

thank you for your help!

2 Answers 2

3

EDIT: Missed the SVGZ bit so this is what you probably really want - http://forums.iis.net/p/1175276/1970786.aspx

Ok, quick question...

Have you thought about doing this via the IIS config rather than C#/.net?

In the applicationHost.config you should see the following section

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
    </httpCompression>

You could add the following:

            <add mimeType="image/svg+xml" enabled="true" />

You'd also need to make sure the mimetype for .svg is set in the element

        <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />

(This config wasn't copied off a production server so no completely sure it's correct but it what I've done for other mimetypes)

0

This is now supported in Server 2012.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.