I have created a very simple SurfaceController in the *.Core project but when running the web site locally I get "The controller for path '/' was not found or does not implement IController" when accessing a view that uses the controller. It's caused by @{ Html.RenderAction("RenderHeader", "My"); }
What have I missed?
MyController.cs
namespace CloudTest.Core.Controllers
{
class MyController: SurfaceController
{
public ActionResult RenderHeader()
{
return PartialView("~/Views/Partials/_Header.cshtml");
}
}
}
_Header.cshtml
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
<div>
This is the header area!
</div>
SurfaceController from class library is not found
I've created a Visual Studio solution using the UaaS script according to https://our.umbraco.org/documentation/Umbraco-Cloud/Set-Up/Visual-Studio/.
I have created a very simple SurfaceController in the *.Core project but when running the web site locally I get "The controller for path '/' was not found or does not implement IController" when accessing a view that uses the controller. It's caused by
@{ Html.RenderAction("RenderHeader", "My"); }
What have I missed?
MyController.cs
_Header.cshtml
Test.cshtml
Hi Johan,
You should make your class public. If you don't set a access modifier it will be private and can not be used in views
Thanks! That was it. Rookie misstake.
Why aren't references to "umbraco.dll" and "Umbraco.Core.dll" added to the *Core class library project from the beginning?
is working on a reply...