You can't add multiple routes that will match the same thing, it has  
no idea to understand if that integer is a categoryId or a regular id.

You need to combine it with some static text for example, or hardcode  
it per controller.

rules.Add(new PatternRoute("/category/<name>/
<categoryId>/")
              .DefaultForArea().IsEmpty
              .DefaultForController().Is("Category")
              .DefaultForAction().Is("searchresult")
              .Restrict("categoryId").ValidInteger);


if you want it to work regardless of controller, you need to either  
prefix, suffix the integer, or add one more level to it:

new PatternRoute("/<controller>/<name>/cat/<categoryId>/ ...

which would give you /someController/SomeName/cat/12345/

On 11 feb 2009, at 23:53, eyal wrote:

>
> Hi All,
>
> I'm trying to add multiple routing rules and it seems that only the
> first rule is actually added
> What am I doing wrong here?
> here is my attempt:
>
>        public static void Register(IRoutingRuleContainer rules)
>        {
>
>            rules.Add(new PatternRoute("/<controller>/<name>/
> <categoryId>/")
>              .DefaultForArea().IsEmpty
>              .DefaultForAction().Is("searchresult")
>              .Restrict("categoryId").ValidInteger);
>
>            rules.Add(new PatternRoute("/<controller>/<name>/<Id>/")
>                .DefaultForArea().IsEmpty
>                .DefaultForAction().Is("view")
>                .Restrict("Id").ValidInteger);
>            // you can add as many rules as you want
>
>
>        }
>
> Cheers
> eyal
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to