Skip to content
This repository was archived by the owner on Nov 27, 2018. It is now read-only.
This repository was archived by the owner on Nov 27, 2018. It is now read-only.

RouteTemplate does not take RouteData #90

@yishaigalatzer

Description

@yishaigalatzer

Consider the following scenario:

    public class CountryRoute : TemplateRoute
    {
        public CountryRoute(IRouter target, string routeName, string routeTemplate, 
            IDictionary<string, object> defaults, IDictionary<string, object> constraints, 
            IInlineConstraintResolver inlineConstraintResolver) : 
            base(target, routeName, routeTemplate, defaults, constraints,  inlineConstraintResolver)
        {
        }

        public override Task RouteAsync(RouteContext context)
        {
            var host = context.HttpContext.Request.Host;

            var split = host.Value.Split(',');

            string countryCode = null;
            if (split.Length > 3)
            {
                countryCode = split[0];
            }

            context.RouteData.Values["Country"] = split;
            return base.RouteAsync(context);
        }
    }

In MVC5 this would produce routevalues in this implementation.

See:
https://github.com/aspnet/Routing/blob/dev/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs#L111

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions