Dashboard widget - is there a simple way to do it?

I have been look a looking for ways to make a episerver Dashboard widget(not sure this is the rigth word for it) with c# + razor or som simple way.

There are some things in the docs about dashboard view, component and container - but no real explanation about what each of them is and how to use them. Any full samples?

I just need some simple component to export some custom data for users and discounts in episerver. Ofcause that could easily be build with a custom site in the website - but I think that it belong in the episerver backend. What is the simple(and right) way to build dashboard widgets for episerver 10?

#183605 Oct 18, 2017 9:02
  • Member since: 2004

    Previously we've used IFrameComponent in WebForms to make quick plugins for EPiServer. Just create an .aspx that has the attribute IFrameComponent and inherits from ContentWebFormsBase.

    [IFrameComponent(Url = "~/Plugins/PublishedTo.aspx", ReloadOnContextChange = true, PlugInAreas = "/episerver/cms/assets", Title = "Document connector", Categories = "cms", MinHeight = 100, MaxHeight = 500)]
        public partial class PublishedTo : EPiServer.Shell.WebForms.ContentWebFormsBase
    // ....

     If you want to use MVC, have a look at this blog post: https://devblog.gosso.se/2017/06/convert-deprecated-gadgets-to-components-in-episerver/

    Good luck!

    #183609 Oct 18, 2017 9:37
  • I have tried making a MVC IFrameComponent from the guide above

    [IFrameComponent(Url = "EventReportComponent",
    Categories = "dashboard",
    Title = "Get reports for Events",
    MinHeight = 300)]
    public class EventReportComponentController : Controller
    //[Authorize(Roles = "WebEditors,WebAdmins")]
    public ActionResult Index()
    return View();
    RouteTable.Routes.MapRoute("EventReportDashboard", "/EventReportComponent/{action}",
    new { controller = "EventReportComponent", action = "index", id = UrlParameter.Optional });

    With the above code I get this exception:

    Can't resolve non-rooted path 'EventReportComponent'

    If I add a slash to: IFrameComponent(Url = "/EventReportComponent", i get this error:

    EPiServer.ServiceLocation.ActivationException: Activation error occurred while trying to get instance of type EPiDashboardController, key "" ---> StructureMap.Building.StructureMapBuildException: Error while building type EPiServer.Shell.ViewComposition.DefaultViewManager.  See the inner exception for details
    1.) new DefaultViewManager(Enumerable of EPiServer.Shell.ViewComposition.IViewProvider with all registered instances, Enumerable of EPiServer.Shell.ViewComposition.IViewTransformer with all registered instances, *Default of IComponentManager*)
    2.) EPiServer.Shell.ViewComposition.DefaultViewManager
    3.) Instance of EPiServer.Shell.ViewComposition.IViewManager (EPiServer.Shell.ViewComposition.DefaultViewManager)
    4.) new Bootstrapper(*Default of IViewManager*, *Default of ModuleTable*, *Default of IClientResourceService*)
    5.) EPiServer.Shell.UI.Bootstrapper
    6.) Instance of EPiServer.Shell.Web.Mvc.IBootstrapper (EPiServer.Shell.UI.Bootstrapper)
    7.) new EPiDashboardController(*Default of IBootstrapper*)
    8.) EPiServer.Shell.UI.Controllers.EPiDashboardController
    9.) Instance of EPiServer.Shell.UI.Controllers.EPiDashboardController
    10.) Container.GetInstance(EPiServer.Shell.UI.Controllers.EPiDashboardController)
     ---> System.ArgumentException: Unable to find a module by assembly 'Vertica.**.Website, Version=, Culture=neutral, PublicKeyToken=null'
    Parameter name: moduleAssembly
       at EPiServer.Shell.Paths.ToResource(Assembly moduleAssembly, String moduleRelativeResourcePath)
       at EPiServer.Shell.ViewComposition.IFrameComponentAttribute.CreateComponentDefinition(Type attributedType)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at EPiServer.Shell.ViewComposition.AttributedComponentProvider.GetComponentDefinitions()
       at EPiServer.Shell.ViewComposition.ComponentManager.ListAll()
       at EPiServer.Shell.ViewComposition.DefaultViewManager..ctor(IEnumerable`1 viewProviders, IEnumerable`1 viewTransformers, IComponentManager componentManager)
       at lambda_method(Closure , IBuildSession , IContext )
       --- End of inner exception stack trace ---
       at lambda_method(Closure , IBuildSession , IContext )
       at StructureMap.Building.BuildPlan.Build(IBuildSession session, IContext context) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\Building\BuildPlan.cs:line 151
       at StructureMap.SessionCache.GetObject(Type pluginType, Instance instance, ILifecycle lifecycle) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\SessionCache.cs:line 93
       at StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\SessionCache.cs:line 68
       at StructureMap.Container.GetInstance(Type pluginType) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\Container.cs:line 337
       at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
       --- End of inner exception stack trace ---
       at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
       at EPiServer.Shell.Web.Mvc.ModuleControllerFactory.CreateController(RequestContext requestContext, String controllerName)
       at EPiServer.Shell.Web.Mvc.ModuleMvcHandler.ProcessRequestInit(HttpContextBase httpContext)
       at EPiServer.Shell.Web.Mvc.ModuleMvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

    I seems to be goging well a good part of the way until it somehow expects something different?!
    (I ofcause have the IFrameComponent in the same assembly as the websitet)

    #184502 Oct 30, 2017 8:48