Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc MVC3中的DiskCache插件imageresizer_Asp.net Mvc_Image Processing_Imageresizer_Image Caching - Fatal编程技术网

Asp.net mvc MVC3中的DiskCache插件imageresizer

Asp.net mvc MVC3中的DiskCache插件imageresizer,asp.net-mvc,image-processing,imageresizer,image-caching,Asp.net Mvc,Image Processing,Imageresizer,Image Caching,对于我的MVC项目(图像服务器应用程序),我无法使用imageresizer进行缓存。我可以像这样访问我的映像,映像源可以是文件系统/数据库(Dependency injeciton): localhost/images/123.jpg?宽度=500 localhost/images/123?宽度=500 我有一个MVC3项目,路线如下 routes.RouteExistingFiles = true; routes.IgnoreRoute("{resource}

对于我的MVC项目(图像服务器应用程序),我无法使用imageresizer进行缓存。我可以像这样访问我的映像,映像源可以是文件系统/数据库(Dependency injeciton):

localhost/images/123.jpg?宽度=500
localhost/images/123?宽度=500

我有一个MVC3项目,路线如下

        routes.RouteExistingFiles = true;
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("favicon.ico");

        routes.MapRoute(
            "ImagesWithExtension", // Route name
            "images/{imageName}.{extension}/", // URL with parameters
            new { controller = "Home", action = "ViewImageWithExtension", imageName = "", extension = "", id = UrlParameter.Optional } // Parameter defaults
        );

        routes.MapRoute(
            "Images", // Route name
            "images/{imageName}/", // URL with parameters
            new { controller = "Home", action = "ViewImage", imageName = "", id = UrlParameter.Optional } // Parameter defaults
        );
我有两个控制器来处理图像 public ActionResult ViewImageWithExtension(字符串imageName,字符串扩展名){} 公共操作结果ViewImage(字符串imageName){}

当URL类似于以下内容时,将完成缓存: localhost/images/123.jpg?width=500,图像源是文件系统
localhost/images/123?width=500缓存不工作映像源是文件系统
localhost/images/123.jpg?width=500缓存不工作,图像源数据库
localhost/images/123?width=500缓存不工作,映像源数据库

我的web配置如下所示:

<configSections>
    <section name="resizer" type="ImageResizer.ResizerSection" />   </configSections>


<resizer>
    <!-- Unless you (a) use Integrated mode, or (b) map all reqeusts to ASP.NET, 
         you'll need to add .ashx to your image URLs: image.jpg.ashx?width=200&height=20 
         Optional - this is the default setting -->
    <diagnostics enableFor="AllHosts" />
    <pipeline fakeExtensions=".ashx" />
    <DiskCache dir="~/MyCachedImages" autoClean="false" hashModifiedDate="true" enabled="true" subfolders="32" cacheAccessTimeout="15000" asyncWrites="true" asyncBufferSize="10485760" />
    <cleanupStrategy startupDelay="00:05" minDelay="00:00:20" maxDelay="00:05" optimalWorkSegmentLength="00:00:04" targetItemsPerFolder="400" maximumItemsPerFolder="1000" avoidRemovalIfCreatedWithin="24:00" avoidRemovalIfUsedWithin="4.00:00" prohibitRemovalIfUsedWithin="00:05" prohibitRemovalIfCreatedWithin="00:10" />
    <plugins>
      <add name="DiskCache" />
    </plugins>   </resizer>

是我做错了什么,还是Imageresizer不支持这种情况?如果没有任何好的插件来使用基于磁盘的图像cahce


提前感谢。

正如我在您同时发布此问题的其他公共论坛中所解释的,ImageResizer从一开始就支持依赖项注入。您试图用更多的依赖项注入来包装依赖项注入,但这是向后的

A) 。您需要使用ImageResizer HttpModule,而不是反对它,以获得良好的性能。这意味着使用URL API,而不是由您自己的MVC ActionResults包装的托管API。更多信息,请收听我的

B) SqlReader、S3Reader、MongoReader、VirtualFolder和AzureReader都支持动态注入,并且可以(只需少量配置)使用相同的路径语法。ImageResizer的设计允许在数据存储之间轻松迁移

C) 您可以使用
Config.Current.Pipeline.Rewrite
事件使URL API使用您想要的任何语法。这比MVC路线灵活得多(而且车辆更少)

D) 如果要添加另一层依赖项注入,请实现
IPlugin
,并动态选择适当的数据存储,然后从
Install
方法对其进行配置