Copied to clipboard

Flag this post as spam?

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


  • Jason D 75 posts 247 karma points
    Aug 31, 2021 @ 18:30
    Jason D
    0

    8.16 Umbraco upgrade warning in log view.

    After finally getting some issues ironed out which seemed to get resolved after upgrading Umbraco and Examine, I have a warning that makes sense, but I'm not sure exactly what to do about it. Is the below warning due to the upgrade and so it's now changed how to implement a custom controller (hijack)?

    I do sort of understand the possibility that using the name "Search" for the view (/Views/Search.cshtml) and the Controller (/Controllers/SearchController.cs), could be a problem(?)

     The current Document Type "search" matches a locally declared controller of type "USD.CMS.Controllers.SearchController". Custom Controllers for Umbraco routing must implement '"Umbraco.Web.Mvc.IRenderController"' and inherit from '"System.Web.Mvc.ControllerBase"'.
    
  • Luuk Peters 85 posts 330 karma points
    Sep 01, 2023 @ 09:45
    Luuk Peters
    100

    Although this is an old question, I'll answer it for other people. As far as I can tell, this warning is not a problem perse. To be honest, I think this should be an INFO record, not a warning.

    In Umbraco it's possible to 'hijack' an Umbraco route. This means that you implement a custom controller for handling the request for a specific document type. The way this is done, is by creating a Controller with a name of [DocumentTypeAlias]Controller. This controller needs to inherit from ControllerBase and implement IRenderController. If you do this, Umbraco will automatically route any request to a node that is of the specified document type to this controller for you to do custom magic on it. Although it's slightly different in Umbraco 12, the principle is the same: https://docs.umbraco.com/umbraco-cms/reference/routing/custom-controllers/.

    So if you have a controller that matches a document type alias, but doesn't Implement ControllerBase and implement IRenderController, you will get the above warning. You probably have a document type with an Alias 'search' and Umbraco sees that you have a controller called SearchController. I guess this warning is meant to make you aware of this in case you wanted to do route hijacking. But as far as I can tell, you can simply ignore the warning if you explicitly don't want route hijacking. I haven't found a way to make Umbraco simply skip this warning (yet?).

Please Sign in or register to post replies

Write your reply to:

Draft