London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
I got it to work like this. You need to make sure you call it before Configure. Unfortunatley HttpConfiguration does not like when there are multiple => configure() called.
using System; using System.Linq; using System.Web.Http; using EPiServer.Framework; using EPiServer.Framework.Initialization; namespace ServiceApi.Test.Business { [InitializableModule] [ModuleDependency(typeof(EPiServer.Framework.FrameworkInitialization))] public class TestAttributeRouting : IInitializableModule { public void Initialize(InitializationEngine context) { GlobalConfiguration.Configuration.MapHttpAttributeRoutes(); } public void Preload(string[] parameters) { } public void Uninitialize(InitializationEngine context) { //Add uninitialization logic } } }
The main reason we added this was becasue if other third party libraries were calling MapAttirbutes then there would be an error. If you are just using attibute routing then letting ServiceApi map them should be sufficient.
EPiServer Service API integration module provides a way to "delay" attribute based routing registartion and delegate that to some external code by adding following key to:
However this seems not to work properly. Tried following solutions:
Added this code to following places:
a) Added to Application_Start()
b) Added to overridden Global.RegisterRoutes()
c) Created initializable module with dependency to EPiServer.ServiceApi.IntegrationInitialization
Called directly GlobalConfiguration.Configuration.MapHttpAttributeRoutes() and then GlobalConfiguration.Configuration.EnsureInitialized().
None of these seems to have any effect.
ServiceApi services ends with error message like:
[InvalidOperationException: The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup code after all other initialization code.] System.Web.Http.Routing.RouteCollectionRoute.get_SubRoutes() +101 System.Web.Http.Routing.RouteCollectionRoute.GetRouteData(String virtualPathRoot, HttpRequestMessage request) +63 System.Web.Http.WebHost.Routing.HttpWebRoute.GetRouteData(HttpContextBase httpContext) +107 System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +233