I've been trying out Asp.NET Core, specifically Areas. Right now I'm running into an issue where I get an exception if I add more than one view to my controller.
This is my exception:
An unhandled exception occurred while processing the request.
AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:
Forum.Areas.Admin.Controllers.AdminController.Index (Forum) Forum.Areas.Admin.Controllers.AdminController.Testing (Forum)
This is how I register the route:
app.UseMvc(routes =>
{
routes.MapRoute("adminRoute", "Admin/{controller}/{action}/{id?}");
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
My controller:
namespace Forum.Areas.Admin.Controllers
{
[Area("Admin")]
[Route("admin")]
public class AdminController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult Testing()
{
return Content("Testing area!");
}
}
}
My project structure:
Other similar questions seem to have ambiguous actions over different controllers, but in my case it's two different action names? Did I register the route wrong?
Edit: please no comments on my "2 spaces for tabs" indentation - it's a style guide from work, I have no say in it :(
Thanks in advance!