DefaultHttpControllerActivator is optimized for a single ControllerDescriptor. We should have one instance of controller activator per controller descriptor. Our current code create a single instance of DefaultHttpControllerActivator and uses it all across.
Try the sample code,
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute("REST", "{controller}");
HttpServer server = new HttpServer(config);
HttpClient client = new HttpClient(server);
client.GetAsync("http://localhost/" + "Controller1").Wait();
client.GetAsync("http://localhost/" + "Controller2").Wait();
client.GetAsync("http://localhost/" + "Controller3").Wait();
Assert.Null(Controller1Controller.Descriptor.Properties.Values.OfType<Func<IHttpController>>().SingleOrDefault());
Assert.NotNull(Controller2Controller.Descriptor.Properties.Values.OfType<Func<IHttpController>>().SingleOrDefault());
Assert.NotNull(Controller3Controller.Descriptor.Properties.Values.OfType<Func<IHttpController>>().SingleOrDefault());
}
Try the sample code,
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute("REST", "{controller}");
HttpServer server = new HttpServer(config);
HttpClient client = new HttpClient(server);
client.GetAsync("http://localhost/" + "Controller1").Wait();
client.GetAsync("http://localhost/" + "Controller2").Wait();
client.GetAsync("http://localhost/" + "Controller3").Wait();
Assert.Null(Controller1Controller.Descriptor.Properties.Values.OfType<Func<IHttpController>>().SingleOrDefault());
Assert.NotNull(Controller2Controller.Descriptor.Properties.Values.OfType<Func<IHttpController>>().SingleOrDefault());
Assert.NotNull(Controller3Controller.Descriptor.Properties.Values.OfType<Func<IHttpController>>().SingleOrDefault());
}