This exeception is coming on browsing.
System.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. at System.Web.Http.Routing.RouteCollectionRoute.get_SubRoutes() at System.Web.Http.Routing.RouteCollectionRoute.GetRouteData(String virtualPathRoot, HttpRequestMessage request) at System.Web.Http.WebHost.Routing.HttpWebRoute.GetRouteData(HttpContextBase httpContext)
I'm having the same issue. GlobalLink is involved here as well. It seems GlobalLinks configuration takes precedence over mine. Rahul Dikkar, did you manage to solve this?
Coming late here, but I've actually writen a blog post about this kind of an issue: https://swapcode.wordpress.com/2020/01/12/broken-web-api-attribute-routing/
In short, most likely the issue is caused by a third party add-on which is calling 'GlobalConfiguration.Configure' method but not calling in the implementation to 'config.MapHttpAttributeRoutes()' - and when your code tries to call the Configure method mapping the http attribute routes it will not work as the Configure method has one time logic (Configure method can be called many times but the MapHttpAttributeRoutes() call must be done when called the first time otherwise it will not work in the later calls).
Hi Team,
Recently I have upgraded to the GlobalLink 11.4.3 version. But after upgrade we are facing object not initialized issue in our application.
We have web api attribute routine defined in WebApiConfig.cs initialize model. See below code for reference,
[InitializableModule]
[ModuleDependency(typeof(FrameworkInitialization))]
public class WebApiConfig : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
// Enable Web API routing
GlobalConfiguration.Configure(config =>
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
});
}
/// <inheritdoc />
public void Uninitialize(InitializationEngine context)
{
}
}
config.MapHttpAttributeRoutes(); is creating problem with GlobalLink 11.4.3.
when I comment this line application works but the web api's not working. I tried to add this in register method and injected dependency in Application_Start methos as well but still its not working.
Please suggest something so that I can use GlobalLink latest version and attribute routine seemlessly in my application.
Thanks,
Rahul Dikkar