【问题标题】:Use ImageResizer with view precompilation in ASP.NET MVC在 ASP.NET MVC 中使用 ImageResizer 和视图预编译
【发布时间】:2017-07-22 10:24:01
【问题描述】:

我在我的 ASP.NET MVC 网站中使用ImageResizer library。我试图打开视图预编译以加快首页加载时间,并且图像缩放器停止工作。尝试访问调整大小的图像时收到以下 404 消息:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

在 ImageResizer 的调试输出(如下所示)中,它显示“(警告):预编译已启用。图像提供程序可能无法按预期工作。”

有没有办法让他们一起工作?

故障排除指南说找不到文件错误可能是因为“您 (a) 没有指定命令字符串,(b) 启用了预编译,并且 (c) 正在使用图像提供程序。这是由.NET 框架中长期存在的错误。”什么是命令字符串?如果我指定一个命令字符串,它会起作用吗?如果是这样,我该怎么做?

调试输出:

Image resizer diagnostic sheet      3/2/2017 3:31:20 PM

2 Issues detected:

(Warning):  To potentially see additional errors here, perform an image resize request.


(Warning):  Precompilation is enabled. Image providers may not work as expected.



You are using plugins from the Performance Edition: DiskCache (Performance Edition), AzureReader2Plugin (Performance Edition)

Registered plugins:

ImageResizer.Plugins.Basic.DefaultEncoder
ImageResizer.Plugins.Basic.NoCache
ImageResizer.Plugins.Basic.ClientCache
ImageResizer.Plugins.Basic.Diagnostic
ImageResizer.Plugins.Basic.SizeLimiting
ImageResizer.Plugins.MvcRoutingShim.MvcRoutingShimPlugin
ImageResizer.Plugins.DiskCache.DiskCache
ImageResizer.Plugins.AzureReader2.AzureReader2Plugin

Configuration:

<resizer>
<clientcache minutes="1440" />
<sizelimits imageWidth="0" imageHeight="0" totalWidth="3200" totalHeight="5000" totalBehavior="throwexception" />
<diagnostics enableFor="allhosts" />
<plugins>
<add name="MvcRoutingShim" />
<add name="DiskCache" />
<add name="AzureReader2" connectionString="[redacted]" endpoint="[redacted]" lazyExistenceChceck="True" prefix="~/assets/" />
</plugins>
</resizer>


Accepted querystring keys:

quality, format, thumbnail, maxwidth, maxheight, width, height, w, h, scale, stretch, crop, cropxunits, cropyunits, page, bgcolor, rotate, flip, sourceFlip, sFlip, sRotate, borderWidth, borderColor, paddingWidth, paddingColor, ignoreicc, frame, useresizingpipeline, cache, process, margin, anchor, dpi, mode, zoom, 

Accepted file extensions:

bmp, gif, exif, png, tif, tiff, tff, jpg, jpeg, jpe, jif, jfif, jfi, 

Environment information:

Running Microsoft-IIS/8.0 on Microsoft Windows NT 6.2.9200.0 and CLR 4.0.30319.42000
Trust level: Unrestricted
OS bitness: x86 !! Warning, running as 32-bit on a 64-bit OS(AMD64). This will limit ram usage !!
Executing assembly: D:\Windows\SysWOW64\inetsrv\w3wp.exe
IntegratedPipeline: True

...
...

【问题讨论】:

    标签: c# asp.net-mvc http-status-code-404 imageresizer


    【解决方案1】:

    预编译会破坏所有 VirtualPathProviders。我们已经做了各种缓解措施,但你切断了 ImageResizer 的版本号,所以我真的帮不上什么忙。

    如果您切换到 Async HttpModule,您可能会有更多的运气。

    在 Web.config 中将 type="ImageResizer.InterceptModule"/&gt; 替换为 type="ImageResizer.AsyncInterceptModule"/&gt;

    【讨论】:

    • 好的,谢谢 Nathanael。使用 AsyncInterceptModule 时有什么需要注意的问题吗?可用的版本号是什么?
    • 并非如此。 4.x
    猜你喜欢
    • 2010-09-27
    • 1970-01-01
    • 2018-08-08
    • 2018-03-13
    • 1970-01-01
    • 2012-10-18
    • 2011-08-13
    • 1970-01-01
    • 2013-02-27
    相关资源
    最近更新 更多