【发布时间】:2020-06-17 17:20:50
【问题描述】:
我正在尝试让 ImageResizer 与 TinyCache 插件一起使用。 (我将使用 ImageResizer Essential Edition)。
我在 Windows 10 / IIS 10.0 集成模式下
我有一个 .net webform 4.7.2 网站,其中安装了以下 NuGet 包:
- ImageResizer (v4.2.5)
- ImageResizer.Plugin.TinyCache (v4.2.5)
- ImageResizer.WebConfig (v4.2.5)
我的 web.config 如下:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!--<section name="resizer" type="ImageResizer.ResizerSection" requirePermission="false" />-->
<section name="resizer" type="ImageResizer.ResizerSection,ImageResizer" requirePermission="false" />
</configSections>
<!--check URL ~/resizer.debug.ashx-->
<resizer>
<!--Unless you (a) use Integrated mode, or (b) map all requests to ASP.NET,
you'll need to add .ashx to your image URLs: image.jpg.ashx?width=200&height=20
Using IIS7 Integrated mode or the Visual Studio web server? You can skip this step.
You also don't need to do this if you are using the .jpg.ashx syntax.-->
<pipeline fakeExtensions=".ashx" defaultCommands="autorotate.default=true" />
<plugins>
<add name="TinyCache" />
<!--<add name="VirtualFolder" virtualPath="~/" physicalPath="..\Assets" vpp="false "/>-->
<!--<add name="VirtualFolder" virtualPath="~/" physicalPath="../Assets" vpp="false "/>-->
</plugins>
</resizer>
<system.web>
<customErrors defaultRedirect="YourErrorPage.aspx"
mode="RemoteOnly">
</customErrors>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
</controls>
</pages>
<httpModules>
<!-- This is for IIS7/8 Classic Mode and Cassini-->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</httpModules>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<!--This is for IIS7+ Integrated mode-->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</modules>
</system.webServer>
</configuration>
当我禁用 TinyCache 插件(只需注释 <add name="TinyCache" /> 行)时,它会在我尝试调用图像调整大小时起作用(例如 http:///Assets/TestImage.jpg?height=100 ;调整图像大小;这里我的网站根目录下的Assets文件夹中有一张TestImage.jpg图片)
但是,我在诊断页面 http:///resizer.debug.ashx 上收到警告,表明我应该启用缓存:
(Warning): NoCache is only for development usage, and cannot scale to production use.
所以我在 web.config 中启用了 TinyCache 插件。
然后我在诊断页面 http:///resizer.debug.ashx 上收到一条警告,我无法摆脱它:(Warning): To potentially see additional errors here, perform an image resize request.
如果我尝试调整图片大小(例如 http:///Assets/TestImage.jpg?height=100 .... 或事件(例如 http:///Assets/TestImage.jpg.ashx?height= 100 在我的情况下我不需要 Win10 - IIS 10 集成模式)我收到以下错误:
注意:这个错误的英文版本(我是法语)是
找不到资源。
描述:HTTP 404。您要查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请检查以下 URL 并确保其拼写正确。
值得注意的是,文件 /App_Data/tiny_cache.cache 永远不会创建! (但是,我已将此文件夹的所有权限授予运行 IIS 池的用户......以及我的 DEV 框上的所有用户!)
如果您有任何想法/解决方案,非常感谢您!
我正在考虑使用 https://imageprocessor.org/ 而不是 ImageResizer,因为没有任何痛苦:)
【问题讨论】:
-
您能附上图片或复制/粘贴您遇到的错误吗?它没有通过。
-
哎呀抱歉,图片不是你的权利。我已经编辑了帖子????
-
您是否尝试安装 protobuf-net 依赖项? nuget.org/packages/protobuf-net
标签: c# imageresizer