1

私のMVCプロジェクト(Image Server Application)の場合、imageresizerを使用してキャッシュを実行できません。私はこのように私の画像にアクセスすることができ、画像ソースはファイルシステム/データベース(依存関係の注入)のいずれかである可能性があります:

localhost / images / 123.jpg?width = 500
localhost / images / 123?width = 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
        );

画像を処理するコントローラーが2つありますpublicActionResultViewImageWithExtension(string imageName、string extension){} public ActionResult ViewImage(string imageName){}

URLが次のようになっている場合にキャッシュが実行されます:localhost / images / 123.jpg?width = 500、画像ソースがFileSystem
localhost / images / 123?width=500キャッシュが機能しない画像ソースがFilesystemlocalhost
/ images / 123.jpg ?width = 500キャッシュが機能しない、イメージソースDB
localhost / images / 123?width = 500キャッシュが機能しない、イメージソースDB

私の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を使用するための適切なプラグインがない場合は?

前もって感謝します。

4

1 に答える 1

3

この質問を同時に投稿した他の公開フォーラムで説明したように、ImageResizer は依存性注入をゼロからサポートしています。依存性注入をより多くの依存性注入でラップしようとしていますが、後方です。

A) ASP.NET MVC 3 および 4 は、設計上、効率的なディスク キャッシュを妨げます。優れたパフォーマンスを得るには、ImageResizer HttpModule に反対するのではなく、操作する必要があります。これは、独自の MVC ActionResults によってラップされたマネージ API ではなく、URL API を使用することを意味します。詳細については、Scott Hanselman とのポッドキャストを聞いてください。

B) SqlReader、S3Reader、MongoReader、VirtualFolder、および AzureReader はすべて動的インジェクションをサポートし、(ほんの少しの構成で) すべて同じパス構文を使用できます。ImageResizer は、データ ストア間で簡単に移行できるように設計されています。

C)Config.Current.Pipeline.Rewriteイベントを使用して、URL API に任意の構文を使用させることができます。これは、MVC ルートよりもはるかに柔軟です (そしてバグが少なくなります)。

D) 依存性注入の別のレイヤーを追加する場合は、 を実装IPluginし、適切なデータ ストアを動的に選択してInstallメソッドから構成します。

于 2012-03-26T12:42:32.317 に答える