在iis中启用svg解压
我尝试在 iis 中启用 SVGZ,但遇到了一些麻烦。这就是我所做的:我向iis控制台添加了一个svgz mime类型,并编译了一个dll来处理解压,我将其添加到“ISAPI Filter”控制台:
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);
}
}
}
但它似乎仍然不起作用...有没有这段代码有错误吗?有什么我忘记的吗?
这是我在浏览器中收到的错误:
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.
谢谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:错过了 SVGZ 位,所以这可能是您真正想要的 - http://forums.iis.net/p/1175276/1970786.aspx
好的,快速提问...
您是否考虑过通过IIS 配置而不是 C#/.net?
在 applicationHost.config 中,您应该看到以下部分
您可以添加以下内容:
您还需要确保在元素中设置 .svg 的 mimetype
(此配置不是从生产服务器复制的,因此不能完全确定这是正确的,但这是我对其他模仿类型所做的)
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
You could add the following:
You'd also need to make sure the mimetype for .svg is set in the element
(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)
Server 2012 现在支持此功能。
This is now supported in Server 2012.