From 06275bc3dc46819851ec1496c148aa8481915fa8 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 16 Nov 2010 10:55:49 -0800 Subject: [PATCH] Correcting ArchiveContraint http://orchard.codeplex.com/workitem/16375 --HG-- branch : dev --- .../Orchard.Blogs/Routing/IsArchiveConstraint.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/IsArchiveConstraint.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/IsArchiveConstraint.cs index e256e0d63..c3d6b71df 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/IsArchiveConstraint.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/IsArchiveConstraint.cs @@ -6,7 +6,18 @@ namespace Orchard.Blogs.Routing { public class IsArchiveConstraint : IRouteConstraint { public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { - return values[parameterName] != null && (new ArchiveData(values[parameterName].ToString())).Year > 0; + if(values[parameterName] == null) { + return false; + } + + try { + var archiveData = new ArchiveData(values[parameterName].ToString()); + archiveData.ToDateTime(); + return true; + } + catch { + return false; + } } } } \ No newline at end of file