在专用服务器上使用ImageResizer和Disk Cache插件多年后,我们正在逐步将我们的网站迁移到Microsoft Azure。不幸的是我遇到了ImageResizer AzureReader2插件的问题。
我的测试图像托管在Azure云存储容器中。使用NuGet将ImageResizer插件添加到新的空MVC Web项目中。如果我在没有QueryString的情况下请求图像,则ImageResizer的响应是302重定向到直接blob URL。
e.g。
http://localhost:50505/azure/bhjrbbgljx.jpg -->
https://jetpress.blob.core.windows.net/media/bhjrbbgljx.jpg
但是,添加QueryString以执行调整大小会导致404找不到响应。
e.g。
http://local.host:50505/azure/bhjrbbgljx.jpg?width=200 --> 404 page
经过大量搜索后,我无法发现其他有类似问题的人。问题Resizing an image using AzureReader2 results in 404不适用,因为我仍然通过VS2013在IIS Express上运行。
详细错误信息
Module
IIS Web Core
Notification
MapRequestHandler
Handler
StaticFile
Error Code
0x80070002
Requested URL
http://localhost:50505/azure/bhjrbbgljx.jpg?width=200
Physical Path
E:\projects\Websites.AzureMedia\JETPRESS.Web.Websites.AzureMedia\azure\bhjrbbgljx.jpg
Logon Method
Anonymous
Logon User
Anonymous
Request Tracing Directory
C:\Users\davidc\Documents\IISExpress\TraceLogFiles\JETPRESS.WEB.WEBSITES.AZUREMEDIA
的web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="resizer" type="ImageResizer.ResizerSection" requirePermission="false" />
</configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Configuration" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="1.8.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<httpModules>
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</modules>
</system.webServer>
<resizer>
<diagnostics enableFor="Localhost" />
<plugins>
<add name="MvcRoutingShim" />
<add name="AzureReader2"
connectionString="[redacted]"
endpoint="https://jetpress.blob.core.windows.net/media/" />
</plugins>
</resizer>
</configuration>
resizer.debug
Image resizer diagnostic sheet 20/10/2014 14:38:41
2 Issues detected:
(Warning): To potentially see additional errors here, perform an image resize request.
(Warning): NoCache is only for development usage, and cannot scale to production use.
Add DiskCache or CloudFront for production use
You are using plugins from the 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.AzureReader2.AzureReader2Plugin
Configuration:
<resizer>
<diagnostics enableFor="Localhost" />
<plugins>
<add name="MvcRoutingShim" />
<add name="AzureReader2" connectionString="[redacted]" endpoint="https://jetpress.blob.core.windows.net/media/" />
</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.1.7601 Service Pack 1 and CLR 4.0.30319.18444
Trust level: Unrestricted
OS bitness: x86 !! Warning, running as 32-bit on a 64-bit OS(AMD64). This will limit ram usage !!
Executing assembly: C:\Program Files (x86)\IIS Express\iisexpress.exe
IntegratedPipeline: True
Loaded assemblies:
mscorlib Assembly: 4.0.0.0 File: 4.0.30319.18444 Info: 4.0.30319.18444
System.Web Assembly: 4.0.0.0 File: 4.0.30319.34237 Info: 4.0.30319.34237
System Assembly: 4.0.0.0 File: 4.0.30319.34238 Info: 4.0.30319.34238
System.Core Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.ApplicationServices Assembly: 4.0.0.0 File: 4.0.30319.34237 Info: 4.0.30319.34237
System.Configuration Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Xml Assembly: 4.0.0.0 File: 4.0.30319.34234 Info: 4.0.30319.34234
System.Runtime.Caching Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
Microsoft.Build.Utilities.v4.0 Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
Microsoft.JScript Assembly: 10.0.0.0 File: 11.0.50938.18408 Info: 11.0.50938.18408
System.Web.Mvc Assembly: 5.2.0.0 File: 5.2.20627.0 Info: 5.2.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
System.Web.WebPages.Deployment Assembly: 3.0.0.0 File: 3.0.20627.0 Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
System.Web.WebPages.Deployment Assembly: 1.0.0.0 File: 1.0.20105.407
System.Web.WebPages Assembly: 3.0.0.0 File: 3.0.20627.0 Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
Microsoft.VisualStudio.Web.PageInspector.Loader Assembly: 1.0.0.0 File: 12.3.50717.0
System.Web.WebPages.Deployment Assembly: 2.0.0.0 File: 2.0.20710.0
System.Web.WebPages.Razor Assembly: 3.0.0.0 File: 3.0.20627.0 Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
Microsoft.VisualStudio.Web.PageInspector.Runtime Assembly: 12.3.0.0 File: 12.3.50717.0
Microsoft.Web.Infrastructure Assembly: 1.0.0.0 File: 1.0.20105.407
App_global.asax.tc0cm6e1 Assembly: 0.0.0.0
JETPRESS.Web.Websites.AzureMedia Assembly: 1.0.0.0 File: 1.0.0.0
System.ServiceModel.Activation Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.Extensions Assembly: 4.0.0.0 File: 4.0.30319.34237 Info: 4.0.30319.34237
Microsoft.CSharp Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Data Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.Services Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Drawing Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.EnterpriseServices Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.IdentityModel Assembly: 4.0.0.0 File: 4.0.30319.34234 Info: 4.0.30319.34234
System.Runtime.Serialization Assembly: 4.0.0.0 File: 4.0.30319.34234 Info: 4.0.30319.34234
System.ServiceModel Assembly: 4.0.0.0 File: 4.0.30319.34234 Info: 4.0.30319.34234
System.ServiceModel.Web Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Activities Assembly: 4.0.0.0 File: 4.0.30319.34234 Info: 4.0.30319.34234
System.ServiceModel.Activities Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.WorkflowServices Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Data.DataSetExtensions Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Xml.Linq Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.ComponentModel.DataAnnotations Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.DynamicData Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
ImageResizer Assembly: 3.4.3.103 File: 3.4.3.103 Info: 3-4-3 Commit: bf92fd7
ImageResizer.Mvc Assembly: 3.4.3.103 File: 3.4.3.103 Info: 3-4-3 Commit: bf92fd7
ImageResizer.Plugins.AzureReader2 Assembly: 3.4.3.103 File: 3.4.3.103 Info: 3-4-3 Commit: bf92fd7
Microsoft.Data.Edm Assembly: 5.6.2.0 File: 5.6.2.61936 Info: 5.6.2.61936
Microsoft.Data.OData Assembly: 5.6.2.0 File: 5.6.2.61936 Info: 5.6.2.61936
Microsoft.Data.Services.Client Assembly: 5.6.2.0 File: 5.6.2.61936 Info: 5.6.2.61936
Microsoft.WindowsAzure.Configuration Assembly: 1.8.0.0 File: 1.8.0.0
Microsoft.WindowsAzure.Storage Assembly: 4.3.0.0 File: 4.3.0.0
Newtonsoft.Json Assembly: 4.5.0.0 File: 5.0.8.16617
System.Spatial Assembly: 5.6.2.0 File: 5.6.2.61936 Info: 5.6.2.61936
System.Web.Helpers Assembly: 3.0.0.0 File: 3.0.20627.0 Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
System.Web.Razor Assembly: 3.0.0.0 File: 3.0.20627.0 Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
System.ServiceModel.Internals Assembly: 4.0.0.0 File: 4.0.30319.34234 Info: 4.0.30319.34234
System.Web.Routing Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.Abstractions Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
SMDiagnostics Assembly: 4.0.0.0 File: 4.0.30319.34234 Info: 4.0.30319.34234
Microsoft.VisualStudio.Web.PageInspector.Tracing Assembly: 12.3.0.0 File: 12.3.50717.0
System.Web.Mobile Assembly: 4.0.0.0 File: 4.0.30319.34237 Info: 4.0.30319.34237
System.Web.RegularExpressions Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Xaml.Hosting Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Xaml Assembly: 4.0.0.0 File: 4.0.30319.18408 Info: 4.0.30319.18408
答案 0 :(得分:2)
AzureReader2需要/azure/container/blob
安装插件时,您可以通过/azure
属性更改prefix="~/path"
前缀。但是,为了从URL中删除容器名称,您需要使用URL重写。
目前,您同时拥有无效的端点和无效的路径。
endpoint="https://jetpress.blob.core.windows.net/media/"
path: /azure/bhjrbbgljx.jpg
相反,这些应该是
endpoint="https://jetpress.blob.core.windows.net/"
path: /azure/media/bhjrbbgljx.jpg
重定向符合串联的巧合;我相信,这让你远离真正的问题。