Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gerhard Grossberger 54 posts 178 karma points
    Oct 05, 2022 @ 15:03
    Gerhard Grossberger
    0

    Maintenance Manager: RenderMvcController

    Hi,

    we wanted to add Maintenance Manager to one of our older pages in Umbraco v8.

    It turns out, it doesn´t work with pages that extend RenderMvcController. Is this a known issue, and is there a workaround?

    Best, Gerhard

  • Kevin Jump 2312 posts 14698 karma points MVP 7x c-trib
    Oct 14, 2022 @ 10:44
    Kevin Jump
    100

    Hi,

    I haven't actually tried it but i think in theory:

    if you have custom controllers that inherit RenderMvcController, you could change that so they inherit MaintenanceModeMvcController and then they too would go through the Maintenace mode process and hit the page as needed.

  • Gerhard Grossberger 54 posts 178 karma points
    Oct 14, 2022 @ 13:20
    Gerhard Grossberger
    0

    Thanks for the quick response!

    It basically works if I do it that way - only a few pitfalls I came across.

    If I use a custom model for the page I´m getting this:

    enter image description here

    So I tried to check the maintenanceService but I can´t access the maintenanceService from the MaintenanceModeMvcController, so I need to add it to every single page.

            public SearchPageController(IGlobalSettings globalSettings, 
                IUmbracoContextAccessor umbracoContextAccessor, 
                ServiceContext services, AppCaches appCaches, 
                IProfilingLogger profilingLogger, 
                UmbracoHelper umbracoHelper, 
                IRuntimeState runtimeState, 
                MaintenanceModeService maintenanceModeService)
            : base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger, umbracoHelper, runtimeState, maintenanceModeService)
        {
            this._maintenanceModeService = maintenanceModeService;
        }
    
        public ActionResult Index(ContentModel<UmbracoModels.Searchpage> model)
        {
            if(_maintenanceModeService.IsInMaintenanceMode)
                return base.Index(model);
    

    So this element fixes the error: if(_maintenanceModeService.IsInMaintenanceMode)

    Ideally, the maintenanceService and the runtimeState and IsBackOfficeUserLoggedIn would be protected instead of private in MaintenanceModeMvcController, then I could access them from my controller.

    The way it is now, I probably have to duplicate the logic in an additional Controller, that I then put in between my controllers and the MaintenanceModeMvcController.

    Not sure if there is a way to cast the model back to it´s original type through reflection.

    But overall, it´s a way to go.

  • Gerhard Grossberger 54 posts 178 karma points
    Nov 02, 2022 @ 10:21
    Gerhard Grossberger
    0

    Got everything to work on my local machine, now we tried to deploy to webserver - and there I get the same issue as described here:

    https://our.umbraco.com/forum/using-umbraco-and-getting-started/102180-maintenance-manager-service-is-not-available

    It works locally, it works if I call the site locally on the server, but it doesn´t work if I call it from the website url. Any ideas?

Please Sign in or register to post replies

Write your reply to:

Draft