Views: 4688
Number of votes: 6
Average rating:

AmbiguousMatchException in MVC BlockController

Have you ever got the following error in the BlockController for our MVC API?

The current request for action 'Index' on controller type 'x' is ambiguous between the following action methods:
System.Web.Mvc.ActionResult Index(y) on type x
System.Web.Mvc.ActionResult Index(y) on type z

If not, you will probably get it in the future. You get this error if you add an action called “Index” in your controller without overriding the index action in the base class. So please, when using a block controller, override the index action, or you may end up with an exception on your EPiServer Tech day presentation.

Nov 09, 2012

Fredrik Stolpe
(By Fredrik Stolpe, 10/28/2014 10:12:04 AM)

A message from the future: I got this error now and this post helped me, thanks :-)

Jens Qvist
(By Jens Qvist, 10/21/2015 5:08:22 PM)

Another message from the future. I got this error and this post helped me also! Thanks! :-D

Glenn Lalas
(By Glenn Lalas, 1/15/2016 5:53:41 PM)

Chiming in from 2016 to continue the trend of confirming how helpful this post was.  Thanks!  :)

Noel Sefton
(By Noel Sefton, 2/5/2019 12:30:28 PM)

yep, helped me as well... (6 years later)

public ActionResult Index(VeryImportantBlock currentBlock) { /*code in here*/ }

becomes

public override ActionResult Index(VeryImportBlock currentBlock) { /* code in here*/ }

Please login to comment.