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 54 posts 107 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 77 posts 433 karma points
    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 54 posts 107 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 77 posts 433 karma points
    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 335 posts 1007 karma points
    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);
        }
    }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies