Try our conversational search powered by Generative AI!

Third-party addon calls MapMvcAttributeRoutes() so that it is called twice.

Vote:
 

Hello,

In my solution I am using inline constraints like this:

var constraintResolver = new DefaultInlineConstraintResolver();
            constraintResolver.ConstraintMap.Add("objectType", typeof(ObjectTypeConstraint));
            constraintResolver.ConstraintMap.Add("market", typeof(MarketConstraint));

            routes.MapMvcAttributeRoutes(constraintResolver);

And in one of the controllers it looks like this:

[Route("{market:market}/{type:objectType}/{county?}/{municipality?}/{city?}/{mainDistrict?}/{district?}/{streetAddress?}", Name = "Search02")]
        public async Task<ActionResult> Index(

However, now I am trying to use the nuget addon TedGustaf.Episerver.AdaptiveImages which is in its Initialization is also calling the method MapMvcAttributeRoutes() but without adding the DefaultInlineConstraintResolver().

This leads to this error message:
"The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: 'objectType'."

Since the addons Initialization is in a "black box", so I cannot remove the method call there, how can i register the DefaultInlineConstraintResolver() without calling the method MapMvcAttributeRoutes() ?

#300584
Apr 23, 2023 11:58
Vote:
 

Hi Hannes

I would say ask the add-on developer to remove their call to MapMvcAttributeRoutes(). Since it can only be called once, the add-on consumer should be able to call it.

They might even be able to omit using attribute routing, if it is not truly necessary.

#300592
Apr 23, 2023 16:45
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.