0

I have an Optimizely 11.20 solution with controllers that use inline route constraints like this:

`[Route("   {market:market}/{type:objectType}/{county?}/{municipality?}/{city?}/{mainDistrict?}/{district?}/{streetAddress?}", Name = "Search02")]

public async Task Index(...`

Where the constrains are registered in Global.asax like this:

`public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("authui/{*pathInfo}");
        routes.IgnoreRoute("util/{*pathInfo}");

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

        routes.MapMvcAttributeRoutes(constraintResolver);
    }`

Now I also have a third party nuget package installed: TedGustaf.Episerver.AdaptiveImage. And when that addon initializes I get this error message:

The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: 'objectType'.

[InvalidOperationException: The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: 'objectType'.] System.Web.Mvc.Routing.InlineRouteTemplateParser.GetInlineConstraint(Group constraintGroup, Boolean isOptional, IInlineConstraintResolver constraintResolver) +479 System.Web.Mvc.Routing.InlineRouteTemplateParser.ParseRouteTemplate(String routeTemplate, IDictionary2 defaults, IDictionary2 constraints, IInlineConstraintResolver constraintResolver) +656 System.Web.Mvc.Routing.DirectRouteFactoryContext.CreateBuilder(String template, IInlineConstraintResolver constraintResolver) +195 System.Web.Mvc.RouteAttribute.System.Web.Mvc.Routing.IDirectRouteFactory.CreateRoute(DirectRouteFactoryContext context) +39 System.Web.Mvc.Routing.DefaultDirectRouteProvider.CreateRouteEntry(String areaPrefix, String controllerPrefix, IDirectRouteFactory factory, IReadOnlyCollection1 actions, IInlineConstraintResolver constraintResolver, Boolean targetIsAction) +112 System.Web.Mvc.Routing.DefaultDirectRouteProvider.CreateRouteEntries(String areaPrefix, String controllerPrefix, IReadOnlyCollection1 factories, IReadOnlyCollection1 actions, IInlineConstraintResolver constraintResolver, Boolean targetIsAction) +201 System.Web.Mvc.Routing.DefaultDirectRouteProvider.GetActionDirectRoutes(ActionDescriptor actionDescriptor, IReadOnlyList1 factories, IInlineConstraintResolver constraintResolver) +154 System.Web.Mvc.Routing.DefaultDirectRouteProvider.GetDirectRoutes(ControllerDescriptor controllerDescriptor, IReadOnlyList1 actionDescriptors, IInlineConstraintResolver constraintResolver) +290 System.Web.Mvc.Routing.AttributeRoutingMapper.AddRouteEntries(SubRouteCollection collector, IEnumerable1 controllerTypes, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider) +178 System.Web.Mvc.Routing.AttributeRoutingMapper.MapAttributeRoutes(RouteCollection routes, IEnumerable`1 controllerTypes, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider) +101 TedGustaf.Episerver.AdaptiveImages.Initialization.AddonInitializationModule.Initialize(InitializationEngine context) +30 EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key) +58 EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context) +123 EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +257

How can I tell the TedGustaf.Episerver.AdaptiveImages initialization to use the DefaultInlineConstraintResolver that have registered the constraints?

I have tried to register the RouteConfig.RegisterRoutes(RouteTable.Routes); further up in the Application_Start() but that did not help.

  • 1
    Hi! I'm a developer for Adaptive Images. That's an old version of Adaptive Images, but it does indeed do `RouteTable.Routes.MapMvcAttributeRoutes();` on initialization. I'll see if there's anything we can do on our end to help. – Ted Nyberg Apr 25 '23 at 08:56
  • 1
    Could you try upgrading to the _preview_ version `1.2.2023.4251-routes` and see if 1) your site starts as expected and 2) images load as expected without Cloudinary (i.e. image URLs starting with "/adaptiveimages/your-provider-name")? You'll find the URL for the NuGet feed with the preview version here: https://adaptiveimages.net/download (look for the MyGet.org URL). – Ted Nyberg Apr 25 '23 at 13:45
  • 1
    Alright, thank you! Also, I solved this by removing the inline constrains in the controller and added the constraints in AreaRegistration instead. But I will look at the new package as well! – Hannes Carleson May 02 '23 at 09:21

0 Answers0