Hi Henrik
I am not sure of the exact answer to your question but I think the Marketing tools makes use of the interceptor feature as described here: http://world.episerver.com/documentation/Release-Notes/ReleaseNote/?releaseNoteId=CMS-3603 and here: http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Initialization/dependency-injection/ and it sounds like it could be intercepting your WebAPI requests too? I could be completely wrong of course!
You could try registering your routes in an Episerver init module and ensuring it executes after the Marketing Testing tools init module EPiServer.Marketing.Testing.Web.Initializers.PublishContentEventListener this will ensure the code you supplied does at least execute after anything the Marketing Testing tools has done.
David
Hi David,
I know how to write initialization modules but how would one write to code to ensure that it runs AFTER the marketing testing tools? Or after any other module?
Currently experiencing the same problems as Henrik
Hi Marcus
You can use the Episerver Debugging tools to look for all init modules: https://www.david-tec.com/2015/02/episerver-debugging-tools/ and look for the marketing testing init module.
Then add a dependency on the Marketing testing init module using the following:
[ModuleDependency(typeof([Name of Marketing testing module]))]
David
Thanks for the link to the EPiServer Debugging tools - a hidden gem!
I managed to solve my problems by using the following code:
[InitializableModule] [ModuleDependency(typeof(EPiServer.Framework.FrameworkInitialization))] public class MyInitializationModule : IInitializableModule { public void Initialize(InitializationEngine context) { // Enable Web API routing GlobalConfiguration.Configure(config => { // Activate CORS config.EnableCors(); // Attribute routing config.MapHttpAttributeRoutes(); // Convention-based routing config.Routes.MapHttpRoute( name: "ActionApi", routeTemplate: "webapi/{controller}/{action}/{id}", defaults: new { id = System.Web.Http.RouteParameter.Optional } ); }); } }
I took dependency on EPiServer.Framework.FrameworkInitialization instead of EPiServer.Web.InitializationModule.
I have a site that uses a lot of webapi 2 within it and now we wanted to try out the EPiServer Marketing Testing Tools.
The installations worked great but suddently all my web api pages stopped working and giving me the error "The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup code after all other initialization code."
I rememberd to have had this problem before when we were trying out Episerver Service Api so I identified it to be how we initialize our routes that do not work with how you are initialize your web api routes.
We do it in global.asax with override of RegisterRoutes and in application_start like this:
How should I change this to make it work with the new Marketing Testing Tools?