How to register Umbraco RenderMvcControllers in glabal asax
I am trying to use RenderMvcController and SurfaceController with dependency injection but it doesn't work.
public class SupplierRenderMvcController : RenderMvcController
{
public HomeRenderMvcController(IMembershipService membershipService)
{
_membershipService = membershipService;
}
}
public class SupplierController : SurfaceController
{
public SupplierController(IMembershipService membershipService)
{
_membershipService = membershipService;
}
}
It is saying:
No parameterless constructor defined for this object.
Umbraco's controllers are registered in in Global.asax:
public class SupplierRenderMvcController : RenderMvcController
{
public HomeRenderMvcController(IMembershipService membershipService)
{
_membershipService = membershipService;
}
}
Shouldn't the constructor be called SupplierRenderMvcController and not HomeRenderMvcController
All my Api controller (inheriting from UmbracoApiController) fail with the same error. They started failing a while ago already and currently I am unable to debug anything i my localhost.
I have to copy dlls into the test and there it fails or not randomly. If it fails I copy more dlls (which have not been changed on the current run) and the site normally picks up.
Same on public site.
But on local it never works.
I fixed my code in the question, the constructor is SupplierRenderMvcController indeed not HomeRenderMvcController but it's still not working.
How to register Umbraco RenderMvcControllers in glabal asax
I am trying to use
RenderMvcControllerandSurfaceControllerwith dependency injection but it doesn't work.It is saying:
Umbraco's controllers are registered in in
Global.asax:I have api controllers using IoC with no problem in other projects of the same solution.
The above controlers are in the main project of the solution though.
This is my full
Global.asaxof the main project:MembershipServiceis registered withinWebApiConfig:is the error referring to this
Shouldn't the constructor be called SupplierRenderMvcController and not HomeRenderMvcController
All my Api controller (inheriting from UmbracoApiController) fail with the same error. They started failing a while ago already and currently I am unable to debug anything i my localhost.
I have to copy dlls into the test and there it fails or not randomly. If it fails I copy more dlls (which have not been changed on the current run) and the site normally picks up.
Same on public site.
But on local it never works.
I fixed my code in the question, the constructor is
SupplierRenderMvcControllerindeed notHomeRenderMvcControllerbut it's still not working.is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.