Hi all,
noticed that adding routes using StopRoutingHandler() throws
NotSupportedExceptions instead of simply ceasing further processing in the
UrlRoutingModule.
Attached is the patch I wrote to change that behavior on master branch,
accompanied with a unit test.
Best,
Damir
From 6917f50523363e4b517d00490cf2e7ffc5d9ccbf Mon Sep 17 00:00:00 2001
From: Damir Simunic damir.simu...@wa-research.ch
Date: Fri, 14 Jan 2011 15:32:13 +0100
Subject: [PATCH] Ignore routes with StopRoutingHandler instead of throwing
---
.../System.Web.Routing/UrlRoutingModule.cs |3 +++
.../System.Web.Routing/UrlRoutingModuleTest.cs | 11 +++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git
a/mcs/class/System.Web.Routing/System.Web.Routing/UrlRoutingModule.cs
b/mcs/class/System.Web.Routing/System.Web.Routing/UrlRoutingModule.cs
index cf8465e..c1a5b2d 100644
--- a/mcs/class/System.Web.Routing/System.Web.Routing/UrlRoutingModule.cs
+++ b/mcs/class/System.Web.Routing/System.Web.Routing/UrlRoutingModule.cs
@@ -119,6 +119,9 @@ namespace System.Web.Routing
if (rd.RouteHandler == null)
throw new InvalidOperationException (No
IRouteHandler is assigned to the selected route);
+ if (rd.RouteHandler is StopRoutingHandler)
+ return; //stop further processing
+
var rc = new RequestContext (context, rd);
IHttpHandler http = rd.RouteHandler.GetHttpHandler (rc);
diff --git
a/mcs/class/System.Web.Routing/Test/System.Web.Routing/UrlRoutingModuleTest.cs
b/mcs/class/System.Web.Routing/Test/System.Web.Routing/UrlRoutingModuleTest.cs
index 7357f1a..a55d911 100644
---
a/mcs/class/System.Web.Routing/Test/System.Web.Routing/UrlRoutingModuleTest.cs
+++
b/mcs/class/System.Web.Routing/Test/System.Web.Routing/UrlRoutingModuleTest.cs
@@ -155,6 +155,17 @@ namespace MonoTests.System.Web.Routing
#endif
// it internally stores the handler
}
+
+ [Test]
+ public void PostResolveRequestCacheStopRoutingHttpHandler ()
+ {
+ var m = new UrlRoutingModule ();
+ RouteTable.Routes.Add (new MyRoute (foo/bar, new
StopRoutingHandler ()));
+ var hc = new HttpContextStub3 (~/foo/bar,
String.Empty, apppath, false);
+ m.PostResolveRequestCache (hc);
+ Assert.IsNull (hc.RewrittenPath, StopRoutingHandler
should stop before the path is rewritten);
+ }
+
[Test]
[Ignore (looks like RouteExistingFiles ( = false) does not
affect... so this test needs more investigation)]
--
1.7.3.3
StopRouteHandler.patch
Description: Binary data
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list