Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Error: AmbiguousActionException: Multiple actions matched.

$
0
0

I'm new to Core and I'm getting this error, what is the cause how do I fix it?

An unhandled exception occurred while processing the request.

<div class="titleerror">AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:

NextJeneration.WebUI.Controllers.HomeController.Index (NextJeneration.WebUI)
NextJeneration.WebUI.Controllers.HomeController.Index (NextJeneration.WebUI)</div>

Microsoft.AspNetCore.Mvc.Internal.ActionSelector.SelectBestCandidate(RouteContext context, IReadOnlyList<ActionDescriptor> candidates)

<div class="page" id="stackpage">
  • AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied: NextJeneration.WebUI.Controllers.HomeController.Index (NextJeneration.WebUI) NextJeneration.WebUI.Controllers.HomeController.Index (NextJeneration.WebUI)

Here is my Controller:

public class HomeController : AmtesControllerBaseController
    {
        public HomeController(IUserRepository repository, NextJeneration.Domain.Concrete.NextJenerationDbContext context) : base(repository, context)
        {
        }

        [AllowAnonymous]
        [Route("")]      // Combines to define the route template "Home"
        [Route("Index")] // Combines to define the route template "Home/Index"
        [Route("/")]     // Does not combine, defines the route template ""
        public async Task<IActionResult> Index()
        {
            bool loggedIn = GetLoggedInStatus();
            if (loggedIn == false)
            {
                var myCAC = getCAC();
                await buildCACuser(myCAC);
            }
            return View();
        }

        [AllowAnonymous]
        [Route("LandingPage")] // Combines to define the route template "Home/LandingPage"
        [HttpGet("[controller]/[action]")]
        public IActionResult LandingPage()
        {
            UserEditViewModel userEditViewModel = new UserEditViewModel();
            var CAC = GetCacInfo();
            var user = userRepository.GetUserByCAC(CAC);
            userEditViewModel.UserStatusId = user.UserStatusId;
            userEditViewModel.Registered = user.Registered;

            if (!user.ThemeId.HasValue)
            {
                userEditViewModel.Theme = "~/lib/bootstrap/dist/css/bootstrap.css";
            }
            else
            {
                userEditViewModel.Theme = userRepository.GetThemeById(user.ThemeId.GetValueOrDefault());
            }

            ViewBag.CSS = userEditViewModel.Theme;

            return View("LandingPage", userEditViewModel);
        }

        //[AllowAnonymous]
        [Route("Error")] // Combines to define the route template "Home/Error"
        public IActionResult Error()
        {
            return View();
        }
    }
</div>

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>