run a method in a controller for a custon dashboard
I'm using the following example code to try to route to a controller for a back-end dashboard.
public class RegisterCustomBackofficeMvcRouteComponent : IComponent
{
private readonly IGlobalSettings _globalSettings;
public RegisterCustomBackofficeMvcRouteComponent(IGlobalSettings globalSettings)
{
_globalSettings = globalSettings;
}
public void Initialize()
{
RouteTable.Routes.MapRoute("cats", _globalSettings.GetUmbracoMvcArea() + "/backoffice/cats/{action}/{id}", new
{
controller = "cats",
action = "meow",
id = UrlParameter.Optional
});
}
public void Terminate()
{
throw new NotImplementedException();
}
}
If the controller is called DashboardController with a method GetAllMediaFolders(), should I change the Initialize to:
public void Initialize()
{
RouteTable.Routes.MapRoute("Dashboard", _globalSettings.GetUmbracoMvcArea() + "/backoffice/Dashboard/{action}/{id}", new
{
controller = "Dashboard",
action = "GetAllMediaFolders",
id = UrlParameter.Optional
});
}
I though this would be the way to do it but the method is not firing (I want it to fire when the dashboard appears), I can however place a breakpoint on the initialize and see that being hit.
Unless you really need to return a view it's best to use WebApi to create an API and consume it in your dashboard with Angular.
If you use a controller that inherits from Umbraco.Web.WebApi.UmbracoAuthorizedApiController Umbraco will map the routes for you as per the top of the docs.
run a method in a controller for a custon dashboard
I'm using the following example code to try to route to a controller for a back-end dashboard.
If the controller is called DashboardController with a method GetAllMediaFolders(), should I change the Initialize to:
I though this would be the way to do it but the method is not firing (I want it to fire when the dashboard appears), I can however place a breakpoint on the initialize and see that being hit.
thanks
Unless you really need to return a view it's best to use WebApi to create an API and consume it in your dashboard with Angular.
If you use a controller that inherits from
Umbraco.Web.WebApi.UmbracoAuthorizedApiController
Umbraco will map the routes for you as per the top of the docs.is working on a reply...