2013-01-17 65 views
3

我一直在我们的网络应用中使用ImageResizer.net,但现在我需要它来调整图像大小,并提供不具有文件扩展名的图像,如下所示:ImageResizer和没有扩展名的图像文件

http://localhost:58306/ClientImages/Batch/2012/12/10/f45198b7c452466684a4079de8d5f85f?width=600 

在这种情况下,我知道我的文件总是TIFF的,但他们没有文件扩展名。

我有什么选择?

/resizer.debug.ashx:https://gist.github.com/raw/9c867823c983f0e5be10/4db31cb21af8b9b36f0aa4e765f6f459ba4b309f/gistfile1.txt

更新

我跟着电脑语言学家的指示:

protected void Application_Start() 
    { 
     Config.Current.Pipeline.PostAuthorizeRequestStart += 
      delegate 
       { 
        var path = Config.Current.Pipeline.PreRewritePath; 
        var clientImgsRelPath = PathUtils.ResolveAppRelative("~/ClientImages/"); 
        var isClientImageRequest = path.StartsWith(clientImgsRelPath, StringComparison.OrdinalIgnoreCase); 

        if (isClientImageRequest) 
         Config.Current.Pipeline.SkipFileTypeCheck = true; 
       }; 


       // other app start code here 
    } 

http://localhost:58306/ClientImages/Batch/2012/12/10/92d67b45584144beb5f791aaaf760252?width=600只是没有调整原始图像大小响应。

这也被问及在这里:http://imageresizing.net/docs/howto/cache-non-images#comment-571615564

这是无论你怎么称呼它与卡西尼开发或Visual Studio Web服务器或期间发生。

回答

2

首先,您必须使用IIS7集成模式。经典模式将不起作用;它不允许ASP.NET访问无延伸请求

除非您明确告知,否则ImageResizer无法知道无扩展名的URL是图片。

本文档介绍:

http://imageresizing.net/docs/howto/cache-non-images

从本质上讲,你最终会执行您的网址逻辑(通常String.StartsWith),以找出是否ImageResizer应该将文件作为图像。

Config.Current.Pipeline.PostAuthorizeRequestStart += delegate(IHttpModule sender, HttpContext context) { 
    string path = Config.Current.Pipeline.PreRewritePath; 

    //Skip the file extension check for everything in this folder: 
    if (path.StartsWith(PathUtils.ResolveAppRelative("~/folder/of/images"), 
     StringComparison.OrdinalIgnoreCase)){ 

     Config.Current.Pipeline.SkipFileTypeCheck = true; 
    } 
}; 

您应该在Global.asax中的Application_Start中注册此事件处理程序。

+0

谢谢,但你能看到我的更新吗? –

+1

您是否试过指定'&process = always'来强制处理作为图像? –