MvcRoutingShim插件无效

时间:2012-06-26 18:32:49

标签: asp.net-mvc asp.net-mvc-routing imageresizer

我正在使用ASP.NET MVC 4项目中的ImageResizer模块,以及插件SqlReader和MvcRoutingShim。

当我尝试访问网址~/databaseimages/123.jpg时(例如),我收到标准错误404 - The resource cannot be found.

我的期望是ImageResizer会处理该请求并尝试从数据库中读取图像,但它甚至没有尝试连接(我使用SQL Profiler来验证这一点)。

有什么不对?

这是/resizer.debug的输出:

Image resizer diagnostic sheet      26-06-2012 20:42:57

1 Issues detected:

(Warning):  To potentially see additional errors here, perform an image resize request.



You are using paid bundles: Cloud Bundle, Performance Bundle

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.SqlReader.SqlReaderPlugin
ImageResizer.Plugins.DiskCache.DiskCache

Configuration:

<resizer>
<plugins>
<add name="MvcRoutingShim" />
<add name="SqlReader" prefix="~/databaseimages/" connectionString="database" idType="UniqueIdentifier" blobQuery="SELECT Content FROM Images WHERE ImageID=@id" modifiedQuery="Select ModifiedDate, CreatedDate From Images WHERE ImageID=@id" existsQuery="Select COUNT(ImageID) From Images WHERE ImageID=@id" requireImageExtension="false" cacheUnmodifiedFiles="true" extensionPartOfId="false" vpp="true" untrustedData="false" />
<add name="DiskCache" />
</plugins>
</resizer>

(...)

1 个答案:

答案 0 :(得分:1)

在您的Web.config文件中,您声明图像ID都是GUID:idType="UniqueIdentifier",但在网址中使用了一个整数:localhost:50272/databaseimages/123.jpg

<add name="SqlReader" prefix="~/databaseimages/" connectionString="database" 
 idType="UniqueIdentifier" requireImageExtension="false" 
 cacheUnmodifiedFiles="true" extensionPartOfId="false"
 vpp="true" untrustedData="false" />

如果您未在URL中指定GUID,则会忽略该请求。将idType更改为其他数据类型(如Int),或在URL中使用正确的数据类型。

来源:http://imageresizing.net/plugins/sqlreader