webadvanced / Structuremap.WebAPI2

Apache License 2.0
12 stars 1 forks source link

Parameterless Constructor Error #8

Closed LBobirca closed 7 years ago

LBobirca commented 7 years ago

I'm getting an error about the controller needing a parameterless public constructor. I've double checked the setup instructions and can't find where I've gone wrong. Any help would be appreciated.

An error has occurred. An error occurred when trying to create a controller of type 'EventsController'. Make sure that the controller has a parameterless public constructor. System.InvalidOperationException at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext() An error has occurred. Type 'EventViewpoint_SinglePage.Controllers.EventsController' does not have a default constructor System.ArgumentException at System.Linq.Expressions.Expression.New(Type type) at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType) at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator) at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)

Thanks, Luisz

LBobirca commented 7 years ago

This is not an issue with Structuremap.WebAPI2. I figured this out. In my startup I was creating a new HttpConfiguration rather than using the GlobalConfiguration.Configuration. After that it was smooth sailing. Sorry for the confusion, but hopefully it will help someone else that has the same issue.