在Linux中使用Mono上的ImageResizer模块时,我得到了以下错误:
Server Error in '/' Application
Argument is out of range. Parameter name: date
Description: HTTP 500. Error processing request.
Stack Trace:
System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: date
at System.Web.HttpCachePolicy.SetLastModified (DateTime date) [0x00046] in /build/src/mono-2.10.8/mcs/class/System.Web/System.Web/HttpCachePolicy.cs:225
at ImageResizer.Caching.ResponseHeaders.DefaultApplyToResponseMethod (IResponseHeaders headers, System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at ImageResizer.Plugins.Basic.NoCacheHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator6.MoveNext () [0x00dad] in /build/src/mono-2.10.8/mcs/class/System.Web/System.Web/HttpApplication.cs:1368
at System.Web.HttpApplication.Tick () [0x00000] in /build/src/mono-2.10.8/mcs/class/System.Web/System.Web/HttpApplication.cs:932
Version information: Mono Runtime Version: 2.10.8 (tarball Sat Dec 31 02:07:23 UTC 2011); ASP.NET Version: 4.0.30319.1以下是调试表:
Image resizer diagnostic sheet 07/09/2012 14:15:41
3 Issues detected:
(Warning): To potentially see additional errors here, perform an image resize request.
(Warning): UrlAuthorizationModule.CheckUrlAccessForPrincipal is not supported on this runtime (are you running Mono?)
It may be possible for users to bypass UrlAuthorization rules you have defined for your website, and access images that would otherwise be protected. If you do not use UrlAuthorization rules, this should not be a concern. You may also re-implement your security rules by handling the Config.Current.Pipeline.AuthorizeImage event.
(Warning): NoCache is only for development usage, and cannot scale to production use.
Add DiskCache or CloudFront for production use
You are not using any paid bundles.
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
Configuration:
<resizer>
<pipeline fakeExtensions=".ashx" />
<plugins>
<add name="MvcRoutingShim" />
</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 Apache on Unix 2.6.39.2 and CLR 4.0.30319.1
Trust level: Unrestricted
OS bitness:
Executing assembly: /usr/bin/mono
IntegratedPipeline: False
Loaded assemblies:
System.Runtime.Caching Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Messaging Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Transactions Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
Mono.Data.Tds Assembly: 4.0.0.0
Mono.Security Assembly: 4.0.0.0
System.Security Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
Mono.CSharp Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
App_global.asax_199cffe9 Assembly: 0.0.0.0
Microsoft.Web.Infrastructure Assembly: 1.0.0.0 File: 1.0.20105.407
dotless.Core Assembly: 1.3.0.3 File: 1.3.0.3 Info: 1.3.0.3
System.Web.WebPages.Razor Assembly: 1.0.0.0 File: 1.0.20105.407
System.Web.WebPages.Deployment Assembly: 1.0.0.0 File: 1.0.20105.407
System.Web.Razor Assembly: 1.0.0.0 File: 1.0.20105.407
ImageResizer Assembly: 3.2.3.302 File: 3.2.3.302 Info: 3-2-beta-3 Commit: 245e873
ImageResizer.Mvc Assembly: 3.2.3.302 File: 3.2.3.302 Info: 3-2-beta-3 Commit: 245e873
System.Web.WebPages Assembly: 1.0.0.0 File: 1.0.20105.407
System.Web.Mvc Assembly: 3.0.0.0 File: 3.0.20105.0
System.Web.Routing Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Web.Helpers Assembly: 1.0.0.0 File: 1.0.20105.407
System.Web.Abstractions Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Web.ApplicationServices Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Data.Linq Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Web.DynamicData Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.ComponentModel.DataAnnotations Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Xml.Linq Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Data.DataSetExtensions Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Web.Extensions Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Core Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.ServiceModel.Web Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 3.5.594.0
System.ServiceModel Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Xaml Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Runtime.Serialization Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.IdentityModel Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.EnterpriseServices Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Drawing Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Web.Services Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Data Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
Microsoft.CSharp Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
Mono.Posix Assembly: 4.0.0.0
Mono.WebServer2 Assembly: 0.4.0.0
mod-mono-server4 Assembly: 2.10.2.0
Mono.Web Assembly: 4.0.0.0 Info: 0.0.0.1
System.Xml Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Configuration Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1
System.Web Assembly: 4.0.0.0 File: 4.0.0.0 Info: 0.0.0.1
mscorlib Assembly: 4.0.0.0 File: 4.0.30319.1 Info: 4.0.30319.1你知道这里会出什么问题吗?
发布于 2012-07-10 00:00:04
从技术上讲,这是Mono中的一个错误- .NET 2.0和.NET 4.0都会在执行转换之前将日期转换为世界时,而mono会将其与本地服务器时间进行比较,甚至无法标准化这两个变量以确保它们具有匹配的时区。
单声道See code
public void SetLastModified (DateTime date)
{
if (date > DateTime.Now)
throw new ArgumentOutOfRangeException ("date");
if (have_last_modified && date < last_modified)
return;
have_last_modified = true;
last_modified = date;
}.NET ( V2和V4) (使用ILSpy,在加载了System.Web的情况下搜索HttpCachePolicy )
或者,单击this link查看反汇编过程。
SetLastModified(DateTime日期)的Psuedocode:
调用代码(ImageResizer),/Core/Caching/ResponseHeaders.cs
//Sets the Last-Modifed: header
//The check against the current time is because files served from another server may have a modified date in the future, if the clocks are not synchronized.
//ASP.NET incorrectly blocks an future modified date from being sent, with an ArgumentOutOfRangeException
DateTime utc = headers.LastModified.ToUniversalTime();
if (utc != DateTime.MinValue && utc < DateTime.UtcNow) {
context.Response.Cache.SetLastModified(utc);
}找到一种不会破坏某些东西的变通方法并不是很简单。MS提供未指定时区的UTC值,而文件系统提供LastModified值,但如果它们来自远程服务器,则可以是将来的值。
由于传入的DateTime值通常不包含时区标志,因此标准化非常重要。
转换为UTC,测试,转换回本地,测试,然后分配可能是一种有效的解决方法。
我建议编辑/Core/Caching/ResponseHeaders.cs,方法DefaultApplyToResponseMethod使用以下语句
if (utc != DateTime.MinValue && utc < DateTime.UtcNow && utc.ToLocalTime() < DateTime.Now) {
context.Response.Cache.SetLastModified(utc.ToLocalTime());
}请让我看看你是否注意到逻辑上的缺陷;如果我它对你有效并通过beta测试,它可能会被集成到未来的版本中。
https://stackoverflow.com/questions/11394971
复制相似问题