在 MVC 中使用带有视图预编译 ASP.NET 图像调整器



我正在 ASP.NET MVC网站上使用ImageResizer库。我尝试打开视图预编译以加快第一页加载时间,但图像缩放器停止工作。尝试访问调整大小的图像时收到以下 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:WindowsSysWOW64inetsrvw3wp.exe
IntegratedPipeline: True
...
...

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

如果你切换到异步HttpModule,你可能会有更多的运气。

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

最新更新