Trouble with Routing.

7 views
Skip to first unread message

James Curran

unread,
Sep 23, 2008, 2:58:59 PM9/23/08
to Castle Project Users
In my Controller, I have two actions (of importance here):
TroupeController.Display(int id)
TroupeController.Display(string name)

and I have (for now) just one routing rule:

PatternRoute pt = new PatternRoute("troupebyname", "/Troupe/
<name>.rails")
.DefaultForController().Is<TroupeController>().DefaultForAction().Is("Display")
.Restrict("name").ValidRegex("[a-zA-Z1-9]+");
RoutingModuleEx.Engine.Add(pt);

Now, if I were to try to use this routing:
http://localhost:20322/Troupe/papermill.rails

One would think (or at least, hope) that this would be routed to the
second Display action. It is however, being routed to the first
(where, naturally, it fails).

What am I doing wrong, and how to I fix it?




James Curran

unread,
Sep 23, 2008, 3:14:42 PM9/23/08
to Castle Project Users
I guess I should add that I will eventually be adding:

pt = new PatternRoute("troupebyid", "/Troupe/<id>.rails")
.DefaultForController().Is<TroupeController>()
.DefaultForAction().Is("Display")
.Restrict("id").ValidInteger;
RoutingModuleEx.Engine.Add(pt);

to route to the first Action list above (as well as a bunch of other
routes), but I just trying to get the one working first.

James Curran

unread,
Sep 23, 2008, 3:26:17 PM9/23/08
to Castle Project Users
With further experimentation, it gets odder. Using the standard URL
form:

http://localhost:20322/Troupe/Display.rails?name=12miles

it gets routed to the correct action, except now the parameter "name"
has the value "Display".

And
http://localhost:20322/Troupe/papermill.rails?name=xxxx

routes "correctly" (i.e. it calls
TroupeController.Display("papermill"); )

hammett

unread,
Sep 23, 2008, 4:20:00 PM9/23/08
to castle-pro...@googlegroups.com
Trunk version? Really?!

--
Cheers,
hammett
http://hammett.castleproject.org/

James Curran

unread,
Sep 23, 2008, 5:11:00 PM9/23/08
to Castle Project Users
On Sep 23, 4:20 pm, hammett <hamm...@gmail.com> wrote:
> Trunk version? Really?!
>

Probably not the absolute latest, but to should be less than a month
old. (I'll update when I get home)

hammett

unread,
Sep 23, 2008, 5:14:34 PM9/23/08
to castle-pro...@googlegroups.com
Maybe it's time for another route overhaul.

--
Cheers,
hammett
http://hammett.castleproject.org/

Ayende Rahien

unread,
Sep 23, 2008, 5:16:26 PM9/23/08
to castle-pro...@googlegroups.com
In that case, what about just using system.web.routes?

hammett

unread,
Sep 23, 2008, 5:18:13 PM9/23/08
to castle-pro...@googlegroups.com
I'd consider supporting it. Not sure I'd like depending on it...

Ken Egozi

unread,
Sep 23, 2008, 5:20:37 PM9/23/08
to castle-pro...@googlegroups.com

hammett

unread,
Sep 23, 2008, 5:53:10 PM9/23/08
to castle-pro...@googlegroups.com
And would also kill our identity.

Ayende Rahien

unread,
Sep 23, 2008, 6:02:03 PM9/23/08
to castle-pro...@googlegroups.com
Is it the routing API that makes MR identity?

hammett

unread,
Sep 23, 2008, 6:05:26 PM9/23/08
to castle-pro...@googlegroups.com
The whole thing, the whole belief system. I wouldnt consider asp.net
mvc's routing perfect and might consider some of their decisions
questionable. Why would I copy their api then?

On Tue, Sep 23, 2008 at 3:02 PM, Ayende Rahien <aye...@ayende.com> wrote:
> Is it the routing API that makes MR identity?

Ayende Rahien

unread,
Sep 23, 2008, 6:13:32 PM9/23/08
to castle-pro...@googlegroups.com
I haven't actually used routing for anything serious, so I don't really consider this to be an interesting part or MR.
As such, I don't have an issue with using this if this make our life easier. If this is a problem, then no, we need to use something that works better.

hammett

unread,
Sep 23, 2008, 6:16:59 PM9/23/08
to castle-pro...@googlegroups.com
I guess donjon was the main source of requirements of the current form
of MR routing.
I admit it's not enough, though, we need more use cases.

Alex Henderson

unread,
Sep 23, 2008, 7:04:40 PM9/23/08
to castle-pro...@googlegroups.com
My biggest concern would be portability - Monorail on mono is actually a really good story and was one of the key selling points for the work I'm doing for a client at the moment (they favor a Linux/mono/MySql based platform for their SaaS branch of the product) - locking in to the MS 3.5 SP1 routing requires either Mono to implement routing themselves, or to maintain a seperate implementaiton of routing for mono in the Castle source/my product (unless the source is available for System.Web.Routing ??) - neither seems a very attractice situation - compared to just having a best of breed routing engine, which could perhaps include an SystemWebRoutingPatternAdaptor to make it easy for developers to use System.Web.Routing patterns in Monorail?

Cheers,

 - Alex

hammett

unread,
Sep 23, 2008, 7:23:19 PM9/23/08
to castle-pro...@googlegroups.com
Very good point, I dont think they are planning to release the routing
code as they did for the mvc.

Victor Kornov

unread,
Sep 23, 2008, 7:39:08 PM9/23/08
to castle-pro...@googlegroups.com
Won't it be available on source servers like the rest of FW? But that will be next to useless in such situation considering license problems.
I guess that could help with internal projects though :)

Alex Henderson

unread,
Sep 23, 2008, 9:12:30 PM9/23/08
to castle-pro...@googlegroups.com
If I was going to bother doing that I might as well just use the System.Web.Routing assembly which I suspect would probably just work as a drop-in replacement.

Ken Egozi

unread,
Sep 24, 2008, 1:53:20 AM9/24/08
to castle-pro...@googlegroups.com
.net 2.0 is a major sell point currently.

And I did not mean using the ms-routing as is.
and also not limiting us.
but rather to try and use the same basic syntax for routes.

The idea is that people with knowledge in MR routing will be able to approach MS-route guys, and help them out more easily - selling MR as a smarter option on the way.

But like ayende, I don't consider it an interesting enough feature to be passionate about.

James Curran

unread,
Sep 24, 2008, 11:57:15 AM9/24/08
to Castle Project Users
To update on the original problem. I was running the truck from early
July (I download & build regularly, but forget to copy it to my
website bin directory).
But even with the latest, the same problems exist. So, I started
single-stepping through the code, to see where things go awry.

First problem: I had, 'new PatternRoute("troupebyname", "/Troupe/
<name>.rails") ' but it wants to be 'new PatternRoute("troupebyname",
"/Troupe/
[name].rails")'. That's probably a bug in the code, as in other
places it accepts either character, but at one spot, it only accepts
"[".

But, that didn't solve the problem, so I continued further. What I
found as in /trunk/Components/Binder/Castle.Components.Binder/
DefaultConverter.cs at about line 33, we have:
else if (inputType == desiredType)
{
exactMatch = true;
}

when what we actually want is:
else if (inputType == desiredType)
{
exactMatch = true;
return true;
}

Which bring up the question... Why isn't that bring the whole system
down?

(I created a patch for that, but since it's just a one-liner someone
may want to just fix it directly)

hammett

unread,
Sep 24, 2008, 12:23:49 PM9/24/08
to castle-pro...@googlegroups.com
After you patched the tests still pass?

--
Cheers,
hammett
http://hammett.castleproject.org/

James Curran

unread,
Sep 24, 2008, 2:02:42 PM9/24/08
to Castle Project Users
Normally, I build with testing off (figuring if it's checked into the
truck, they pass) (also when I started doing this, I didn't have
nUnit on that machine)

Tried building with tests turned on. It failed.
Removed my change and build again. Still failed. Apparently still
some problem with my testing setup. will investigate.

James Curran

unread,
Sep 25, 2008, 3:02:21 PM9/25/08
to castle-pro...@googlegroups.com
On Wed, Sep 24, 2008 at 12:23 PM, hammett <ham...@gmail.com> wrote:
>
> After you patched the tests still pass?

Tests do still pass... but that's mainly because that method is never
called by any of the unit tests. I've written a set to test it, but
it's also being called in SmartDispatchController, and since the
method is never called at all in the unit tests, that means there's a
least one path through SDC that's no being tested either. I'll try to
work out a test for that also.


--
Truth,
James

Reply all
Reply to author
Forward
0 new messages