Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an Area to DashedRouteHandler #13

Open
HoomanBahreini opened this issue Jan 26, 2020 · 0 comments
Open

Adding an Area to DashedRouteHandler #13

HoomanBahreini opened this issue Jan 26, 2020 · 0 comments

Comments

@HoomanBahreini
Copy link

HoomanBahreini commented Jan 26, 2020

I tried the following code to add a new Area, as mentioned in documentation file:

public class B2bAreaRegistration : AreaRegistration
{
    public override string AreaName
    {
        get { return "B2b"; }
    }

    public override void RegisterArea(AreaRegistrationContext context)
    {
        var b2bDefaultRoute = new LowercaseDashedRoute(
            "B2b/{controller}/{action}/{id}",
            new RouteValueDictionary(new { action = "index", id = UrlParameter.Optional }),
            new DashedRouteHandler(),
            //this, 
            //context,
            new[] { "MyDomain.Web.Areas.B2b.Controllers" }
        );
        context.Routes.Add("B2b_default", b2bDefaultRoute);
    }
}

The above code was not setting the Area correctly, i.e. the following was not being set:

    HttpContext.Current.Request.RequestContext.RouteData.DataTokens["area"]

If I uncomment the 2 commented lines, (AreaRegistration and AreaRegistrationConext ) then it would work correctly and it would set the area. However the example in the documentation does not mention anything about these 2 parameters... I am not sure if this is my misunderstanding, or a bug? Or perhaps just an outdated documentation...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant