Copied to clipboard

Flag this post as spam?

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


  • David Veksler 81 posts 166 karma points
    Oct 30, 2015 @ 15:37
    David Veksler
    1

    Umbraco 7.3.0 to 7.3.1 error: 'Controller' is ambiguous between the following action methods

    After upgrading from 7.3.0 to 7.3.1, all the controllers I declared throw an error:

    The current request for action 'Index' on controller type 'DonateController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Index(Umbraco.Web.Models.RenderModel) on type FEE.Web.App_Code.Controllers.DonateController System.Web.Mvc.ActionResult Index(Umbraco.Web.Models.RenderModel) on type Umbraco.Web.Mvc.RenderMvcController

    I don't get why this upgrade caused this issue. The code is very simple:

    public class DonateController : RenderMvcController
        {
            public ActionResult Index(RenderModel model)
            {
                return CurrentTemplate(model);
            }
        }
    
  • Matthieu Nelmes 102 posts 385 karma points
    Oct 30, 2015 @ 17:05
    Matthieu Nelmes
    0

    Try re-saving your template files, I've had this where I've created templates outside of Umbraco (in Visual Studio) and Umbraco hasn't properly referenced the routing. It looks like maybe the update has dropped that info?

    Although it looks like our prayers may be answered in an upcoming version! http://issues.umbraco.org/issue/U4-6946

  • David Veksler 81 posts 166 karma points
    Nov 01, 2015 @ 11:51
    David Veksler
    0

    That did not work unfortunately. I will roll back the DB and try the upgrade again.

    resave

  • David Veksler 81 posts 166 karma points
    Nov 01, 2015 @ 16:00
    David Veksler
    0

    Reverting the code (but not data) to 7.3.0 resolved the error, so it's indeed a bug introduced in 7.3.1.

  • James Strugnell 84 posts 192 karma points
    Nov 01, 2015 @ 21:04
    James Strugnell
    2

    I saw this too but was able to modify my code to resolve it. I'm not sure why it only just started becoming a problem, but I think you can fix this by either adding the 'overrides' keyword to the Index method. Or rename the Index method to be the same as the actual template name, assuming you are route hijacking here?

  • René Pjengaard 117 posts 700 karma points c-trib
    Nov 09, 2015 @ 14:44
    René Pjengaard
    0

    I had the same problem, and James´ solution worked for my project.

    Before:

    namespace vuc.Controllers.Mvc{
    public class VucNyhedController : VucWebsiteUndersideController{
        public ActionResult Index(){
            return View(Nyhed.GetFromContent(CurrentPage));
        }
    }}
    

    after:

    namespace vuc.Controllers.Mvc{
    public class VucNyhedController : VucWebsiteUndersideController{
        public override ActionResult Index(RenderModel model){
            return View(Nyhed.GetFromContent(CurrentPage));
        }
    }}
    

    regards René

  • Veronica Burd 76 posts 201 karma points
    Nov 09, 2015 @ 18:29
    Veronica Burd
    0

    Just encountered this problem today. I used James' other suggestion and renamed my Index method to match the name of my controller e.g.

    namespace cmsHoR.Controllers
    {
        public class PaperLaidController : RenderMvcController
        {
            public ActionResult PaperLaid(PaperLaidFrontendModel model)
            {
               //etc.
            }
       }
    }
    

    Code now works again.

  • James Jackson-South 489 posts 1747 karma points c-trib
    Nov 09, 2015 @ 23:53
    James Jackson-South
    0

    Hi David,

    I'm not sure how your code worked before but it shouldn't have. I imagine there was a bug in the Umbraco pipeline in previous versions that somehow allowed this.

    You are getting the error because you have two method calls with the same name in your controller Index. There is a virtual instance in your base controller plus your instance. The framework simply doesn't know which method is the correct one.

    James and René are both correct.

    Your code should be as follows:

    public class DonateController : RenderMvcController
        {
            public override ActionResult Index(RenderModel model)
            {
                return CurrentTemplate(model);
            }
        }
    

    This tells the framework the override virtual Index method with your own version.

    Veronica - Renaming the method work as the route handler will look for a method matching the document type name first and you have also removed the duplicate method signature from your code.

    I hope that clears a few things up.

    Cheers

    James

  • Timo Perplex 13 posts 145 karma points c-trib
    Nov 12, 2015 @ 13:11
    Timo Perplex
    0

    @James, your solution works, but not with anything other than a RenderModel. What if I have an id or a custom model that i need binded on request.

    I've added an issue for this problem as the given solution isn't suitable for all circumstances.

    See http://issues.umbraco.org/issue/U4-7399

  • Kieron McIntyre 116 posts 359 karma points
    Nov 12, 2015 @ 14:44
    Kieron McIntyre
    0

    The bug is a result of a change to the RenderActionInvoker class. A short term solution is to register a customer controller factory which instantiates the previous version's RenderActionInvoker class.

  • Derek Staszak 15 posts 106 karma points
    Feb 10, 2017 @ 00:09
    Derek Staszak
    0

    I'm not sure if anyone is still on this thread but I just ran into this issue when setting up my local site and upgrading from Umbraco 7.2.6 to 7.5.9.

    The error message i get is:

    The current request for action 'Index' on controller type 'HomePageController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Index(Umbraco.Web.Models.RenderModel) on type DiamFusion.Web.Controllers.HomePageController System.Web.Mvc.ActionResult Index(Umbraco.Web.Models.RenderModel) on type Buzz.Hybrid.Controllers.SurfaceRenderMvcController

    The code for the "HomePageController" is:

    namespace DiamFusion.Web.Controllers { public class HomePageController : WebControllerBase { [DonutOutputCache(CacheProfile = "FiveMins")] public override ActionResult Index(RenderModel model) { return this.CurrentTemplate<>

    I would greatly appreciate any help I can get.

    Thanks, Derek

Please Sign in or register to post replies

Write your reply to:

Draft