ImageResizer 在使用 Visual Studio 进行测试时有效 - 不适用于生产?

ImageResizer works when testing with Visual Studio - not working on production?

我通过 NuGet 安装了 ImageResizer,当我 运行 来自 Visual Studio 的 ASP.Net MVC 网站时,它工作正常。我可以访问 /resizer.debug 页面,它说一切正常。

当我将站点从 Visual Studio 发布到同一台机器上的主 IIS 实例时,ImageResizer 不起作用,当我浏览到 /resizer.debug 时,出现 404 Not Found 错误.

我已经发布了 web.config 并验证了所有图像缩放器组件都在其中。例如:

<httpModules><add name="ImageResizingModule" type="ImageResizer.InterceptModule" /></httpModules></system.web>

ImageResizer dll 也在 /bin 目录中。

但是,没有任何反应,调试页面也不会显示。

发布项目时,是否需要在IIS7上配置ImageResizer?

您似乎只为 IIS Classic 配置了它,而不是 IIS7 Integrated 模式。 必须 是安装了模块的 <system.webServer> 元素。

From the installation guide:

 <?xml version="1.0" encoding="utf-8" ?>
 <configuration>
   <configSections>
     <section name="resizer" type="ImageResizer.ResizerSection,ImageResizer"  requirePermission="false"  />
   </configSections>

   <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 -->
     <pipeline fakeExtensions=".ashx" defaultCommands="autorotate.default=true"/>

     <plugins>
       <add name="DiskCache" />
       <!-- <add name="PrettyGifs" /> -->
       <!-- <add name="SimpleFilters" /> -->
       <!-- <add name="S3Reader" /> -->
     </plugins>  
   </resizer>

   <system.web>
     <httpModules>
       <!-- This is for IIS7/8 Classic Mode and Cassini-->
       <add name="ImageResizingModule" type="ImageResizer.InterceptModule"/>
     </httpModules>
   </system.web>

   <system.webServer>
     <validation validateIntegratedModeConfiguration="false"/>
     <modules>
       <!-- This is for IIS7/8 Integrated mode -->
       <add name="ImageResizingModule" type="ImageResizer.InterceptModule"/>
     </modules>
   </system.webServer>
 </configuration>