【发布时间】:2015-10-30 16:31:01
【问题描述】:
产品使用:来自http://imageresizing.net的ImageResizer.dll
我有一个客户网站,我使用该产品为他们的在线购物车动态调整图像大小。该产品效果很好!我最近添加了一个自定义 HTTPHandler (MyCustomSecurityHandler) 来控制对特定目录中需要保护的图像的访问。只要我不尝试使用 ImageResizer 识别的 QueryString 参数“width”或“height”访问图像,MyCustomSecurityHandler 的代码就可以正常工作。如果没有使用 QueryString 参数,ImageResizer 会忽略请求,而我的 Custom HTTPHandler 会接收请求并完美处理安全性。
问题:如果用户输入具有 ImageResizer.dll 识别属性的图像的直接路径,我的自定义处理程序将被忽略并显示图像。
预期目标:
1) 无论提供的任何查询字符串参数如何,当路径匹配时都会触发我的客户图像处理程序。 (如果我删除 ImageResizer.dll 的 web.config 条目,这将有效)
2) 仅当图像来自以下文件夹或子文件夹时,让 imageresizer.dll 识别 QueryString 参数并进行处理:{SITEROOT}/images/products/
问题:有没有人使用过这个 imageresizer.dll 产品,你能指导我如何配置它以达到我想要的目标吗?
我已经修改了以下配置文件,以显示相关条目我正在使用什么。
{我的安全目录}
我网站上实际路径的占位符值
WebProjectAssembly.HTTPHandlers.MyCustomSecurityHandler
我的自定义 HTTPHandler 类
我的 Web.Config 文件:
<?xml version="1.0"?>
<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>
<httpHandlers>
<add verb="*" path="/{MY SECURE DIRECTORY}/*.jpg" type="WebProjectAssembly.HTTPHandlers.MyCustomSecurityHandler" />
</httpHandlers>
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add verb="*" path="/{MY SECURE DIRECTORY}/*.jpg" name="MyCustomHandler" type="WebProjectAssembly.HTTPHandlers.MyCustomSecurityHandler" />
</handlers>
<modules>
<!--This is for IIS7/8 Integrated mode-->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</modules>
</system.webServer>
</configuration>
【问题讨论】:
标签: c# c#-4.0 httphandler imageresizer