Copied to clipboard

Flag this post as spam?

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


  • Warren Harding 132 posts 275 karma points
    Oct 26, 2020 @ 06:14
    Warren Harding
    0

    Custom MVC Route Just Aint Working

    Hi there, I was hoping someone could help me out with something that is no doubt blatantly obvious, but I'm stuck...

    I am attempting to register a custom MVC route using components and I have done the following:

    1. Created a helper class "UmbracoEvents" with the following:

    enter image description here

    1. Created a controller with the following:

    enter image description here

    But when trying to load this I get the following YSOD:

    enter image description here

    Any help here would be greatly appreciated. Thank you

  • Corné Strijkert 80 posts 456 karma points c-trib
    Oct 26, 2020 @ 21:04
    Corné Strijkert
    2

    Hi Warren,

    I think maybe you have to change your Controller type from Controller to SurfaceController, because your yellow screen makes clear that LightInject is unable to resolve your ToolsController.

    Maybe registering your Controller as a type with composition.Register<ToolsController>() or something like that within a IUserComposerworks as well, but I'm not sure about that.

    Give it a try.

    Corné

  • Warren Harding 132 posts 275 karma points
    Oct 27, 2020 @ 07:45
    Warren Harding
    0

    Interesting.. thank you that's worked.

    I'm not to confident with IUserComposer just yet, but that may have cropped up in the next error I've hit.

  • Corné Strijkert 80 posts 456 karma points c-trib
    Oct 27, 2020 @ 09:03
    Corné Strijkert
    0

    See the documentation for how Composing works:

    https://our.umbraco.com/documentation/implementation/composing/

    Corné

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Oct 27, 2020 @ 10:31
    Huw Reddick
    0

    You can register your controller as below, however I still haven't been able to get a custom route working myself :D

    public class RegisterCustomRouteComposer : ComponentComposer<RegisterCustomRouteComponent>
    {
        public override void Compose(Composition composition)
        {
            //You can do this for a single controller - Lifetime is MEGA important
            composition.Register(typeof(Vantage.Controllers.BusinessController), Lifetime.Request);
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft