What is the correct way to create URL.Actions() for a shared layout used under different baseRoutes?

Imported from the CodePlex archive for reference purposes. Support for MvcCodeRouting has ended.

Commented on

Hi,

I created two map routes like this

routes.MapCodeRoutes(
            baseRoute:="RiskPrime/Transactions",
           rootController:=GetType(RiskPrime.Transactions.DealController)
           )
routes.MapCodeRoutes(
            baseRoute:="RiskPrime/Main",
           rootController:=GetType(RiskPrime.Main.DefaultController)
           )
So I have two baseRoutes, then I have a Layout shared between baseRoutes where I need to render a menu bar like this:  
@Html.Action("UserMenu""Default")
UserMenu action is under baseRoute "RiskPrime/Main". Now, it works when I render a view with a controller under baseRoute "RiskPrime/Main" but it does not work when I try to render a view with a controller under baseRoute "RiskPrime/Transactions". What is the correct way to create URL.Actions() for a shared layout used under different baseRoutes?
Thank you and very good job!
Commented on link

Try this:

@Html.Action("UserMenu", "~~RiskPrime.Main.Default")

I think that should work, let me know.

Commented on link

Thanks for answering.

I actually tried that, I have the same line of code:

 Html.Action("UserMenu""~~RiskPrime.Main.Default")

But I noticed something, I will explain. So I have my login page, right after the user is logged in, I redirect him to the welcome view, the URL looks like this:

/RiskPrime/Main/Welcome

Which is fine, I have a 'Welcome' controller under that baseRoute, and there is a valid route for that, BUT, the welcome view is using the _Layout, and this layout should be rendered including the UserMenu, I try to render this menu with the line of code:

Html.Action("UserMenu", "~~RiskPrime.Main.Default")

But right after this line execution in my _layout.vbhtml, I get the error:

Message=The controller for path '/RiskPrime/Main/Welcome' was not found or does not implement IController.

Now, if I comment out that line where I am trying to render the menu, everything is fine and my Welcome page is rendered successfully.

So, in summary, it seems like the code breaks when I am opening "/RiskPrime/Main/Welcome" but at the same time trying to render a menu under "/RiskPrime/Main/UserMenu", I dont think that route is wrong, it should match both cases, it is kind of weird.

routes.MapRoute(Nothing, "RiskPrime/Main/{action}", _
    New With {.controller = "Default"}, _
    New With {.action = "Welcome|SilverlightMain|NoAccess|UserMenu"}, _
    New String() {"SpectrumSL.Web.RiskPrime.Main"})
Thanks,
Commented on link

I cannot reproduce the issue. I created a project that tries to recreate your routes/controllers and it works fine. If you email me at maxtoroq@gmail.com I can send it to you.

What versions of ASP.NET MVC and MvcCodeRouting are you using?