erichexter / twitter.bootstrap.mvc

nuget package to make bootstrap easy with mvc4
Apache License 2.0
248 stars 134 forks source link

Support for MVC Areas in NavigationRoutes #46

Closed robertdean closed 11 years ago

robertdean commented 11 years ago

Given the following MVC Area Registration:

    public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Admin";
            }
        }
        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                new {controller="main", action = "Index", id = UrlParameter.Optional }
            );
        }
    }

and using the following configuration:

  routes.MapNavigationRoute<MainController>("Admin", c=>c.Index());

When using

  @Html.Navigation()

the extension method will generate the following URL

~/main/index

Instead of

~/Admin
erroric commented 11 years ago

+1

erroric commented 11 years ago

After couple of hours i had written some working code. If you like it, you can pull it into the project :) P.S. IRouteWithArea interface can be also implemented in the NavigationRoute class, adding public Area property for it, but behaviour with DataTokens is more correct way I think (look here for AreaHelpers source code: http://forums.asp.net/t/1530007.aspx/1)

erichexter commented 11 years ago

Thanks for looking at this.. I am going to play with your implementation. I want the default configuration of routes to be as simple as possible so, I am going to see if I can make the API simpler rather then forcing Areas to be registered using the full overload.

Eric Hexter

blog | http://Hex.LosTechies.com info | http://www.linkedin.com/in/erichexter

On Thu, Jan 24, 2013 at 4:27 PM, Локтионов Алексей <notifications@github.com

wrote:

After couple of hours i have written some working code. If you like it, you can pull it into the project :) P.S. class NavigationRoute can aso implements IRouteWithArea interface with public Area property, but behaviour with DataTokens is more correct I think (look here for AreaHelpers source code: http://forums.asp.net/t/1530007.aspx/1)

— Reply to this email directly or view it on GitHubhttps://github.com/erichexter/twitter.bootstrap.mvc/issues/46#issuecomment-12677391.

erichexter commented 11 years ago

support added in the current master branch

erroric commented 11 years ago

Actually, not. I have commented, why, inside my pull request.