Copied to clipboard

Flag this post as spam?

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


  • João Roque 11 posts 95 karma points
    Apr 14, 2021 @ 11:26
    João Roque
    0

    CurentPage bug and improvement sugestion

    Hello.

    I have the following controller and action:

    public class RegisterController : SurfaceController
    {
        private readonly IViewRenderService viewRenderService;
        private readonly UmbracoHelper umbracoHelper;
        private readonly SignInManager<DBUser> signInManager;
        private readonly UserManager<DBUser> userManager;
        private readonly IMapper mapper;
        private readonly DBContext context;
    
        public RegisterController(IUmbracoContextAccessor umbracoContextAccessor,
                              IUmbracoDatabaseFactory databaseFactory,
                              ServiceContext services,
                              AppCaches appCaches,
                              IProfilingLogger profilingLogger,
                              IPublishedUrlProvider publishedUrlProvider,
                              IViewRenderService viewRenderService,
                              UmbracoHelper umbracoHelper,
                              SignInManager<DBUser> signInManager,
                              UserManager<DBUser> userManager,
                              IMapper mapper,
                              DBContext context) : base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider)
        {
            this.viewRenderService = viewRenderService;
            this.umbracoHelper = umbracoHelper;
            this.signInManager = signInManager;
            this.userManager = userManager;
            this.mapper = mapper;
            this.context = context;
        }
    
        [HttpPost]
        public IActionResult Finish(FinishRegistrationFormModel formModel)
        {
            var a = CurrentPage;
            return new EmptyResult();
        }
    }
    

    When I post to the action from a standard HTML form it results in the following exception on the CurrentPage line:

    System.InvalidOperationException: 'No UmbracoRouteValues feature was found in the HttpContext'
    

    I'm pretty sure this is a bug, but don't know if I should have opened an issue on github. Should I, or only contributors can?

    I also have a sugestion. Currently the Index() method of RenderController (used to perform the route hijacks) does not allow being async which is quite a big limitation in my opinion. Or am I missing something?

    Thanks

  • Bjarke Berg 29 posts 265 karma points hq
    Apr 14, 2021 @ 11:32
    Bjarke Berg
    0

    Hi, if you think it is a bug, then create an issue on github using this link: https://github.com/umbraco/Umbraco-CMS/issues/new?assignees=&labels=project%2Fnet-core&template=3_BugNetCore.md

    What URL are you using to hit your controller?

    BR/ Bjarke

  • João Roque 11 posts 95 karma points
    Apr 15, 2021 @ 08:15
    João Roque
    1

    Hi,

    Good think I didn't submit the bug report. Your question made me realize I wasn't using the BeginUmbracoForm helper, and was instead using a regular mvc core form tag. It's fixed now.

    Do you know if the async Index() for RenderController isn't actually supported yet?

    João

Please Sign in or register to post replies

Write your reply to:

Draft