UmbracoAuthorizedApiController - Make sure that the controller has a parameterless public constructor
I am working on an upgrade and have forked the handy work of Kevin Giszewski on the PhoenixConverters project.
I've updated the package dependencies to use the latest Umbraco v7.5.8 but when attempting to access the plugin an exception is thrown saying
An error occurred when trying to create a controller of type 'PhoenixApiController'. Make sure that the controller has a parameterless public constructor..
The controller is pretty simple really and just inherits from UmbracoAuthorizedApiController. Even when adding a parameterless constructor the exception remains.
Am I missing something? It's not any different to other UmbracoAuthorizedApiController instances I've created in the past as far as I can tell.
It could be that the constructor in PhoenixApiController is throwing an exception... this would give you the same (albeit incorrect) error as if there is no constructor.
This is the odd thing because the exception does not appear in the log files. I get it in the browser only but you are correct there is an inner exception thrown:
{
"Message":"An error has occurred.",
"ExceptionMessage":"An error occurred when trying to create a controller of type 'PhoenixApiController'. Make sure that the controller has a parameterless public constructor.",
"ExceptionType":"System.InvalidOperationException",
"StackTrace":" at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
"InnerException":{
"Message":"An error has occurred.",
"ExceptionMessage":"Value cannot be null.\r\nParameter name: umbracoContext",
"ExceptionType":"System.ArgumentNullException",
"StackTrace":" at Umbraco.Web.WebApi.UmbracoApiControllerBase..ctor(UmbracoContext umbracoContext)\r\n at Umbraco.Web.WebApi.UmbracoAuthorizedApiController..ctor()\r\n at PhoenixConverters.Controllers.PhoenixApiController..ctor()\r\n at lambda_method(Closure )\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)"
}
}
I've even tried adding the following constructors but the issue remains:
public class PhoenixApiController : UmbracoAuthorizedApiController
{
public PhoenixApiController() : base(UmbracoContext.Current)
{
}
public PhoenixApiController(UmbracoContext umbracoContext) : base(umbracoContext)
{
}
[...]
}
Seems sooo looong ago now I can't remember exactly but I have just opened up my fork and the PhoenixApiController I have inherits from UmbracoAuthorizedJsonController - see if that helps and let me know?
Edit: Additionally, I have no constructors in the class
UmbracoAuthorizedApiController - Make sure that the controller has a parameterless public constructor
I am working on an upgrade and have forked the handy work of Kevin Giszewski on the PhoenixConverters project.
I've updated the package dependencies to use the latest Umbraco v7.5.8 but when attempting to access the plugin an exception is thrown saying
The controller is pretty simple really and just inherits from
UmbracoAuthorizedApiController
. Even when adding a parameterless constructor the exception remains.Am I missing something? It's not any different to other
UmbracoAuthorizedApiController
instances I've created in the past as far as I can tell.What is the full stack trace? (look in the log).
It could be that the constructor in PhoenixApiController is throwing an exception... this would give you the same (albeit incorrect) error as if there is no constructor.
Hi John,
This is the odd thing because the exception does not appear in the log files. I get it in the browser only but you are correct there is an inner exception thrown:
I've even tried adding the following constructors but the issue remains:
Hi Simon,
I'm having the same issue here. Have you ever managed to get this working?
cheers
Erik
Seems sooo looong ago now I can't remember exactly but I have just opened up my fork and the
PhoenixApiController
I have inherits fromUmbracoAuthorizedJsonController
- see if that helps and let me know?Edit: Additionally, I have no constructors in the class
is working on a reply...