user3224190Aayu
user3224190Aayu

Reputation: 3

MVC 4 Error(how can correct server error in '/' application?)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:

System.Reflection.AmbiguousMatchException: The current request for action 'index' on controller type 'CategoryController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Index() on type Onclickmuseum.Controllers.CategoryController System.Web.Mvc.ActionResult Index(Onclickmuseum.Models.CategoryModel) on type Onclickmuseum.Controllers.CategoryController

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[AmbiguousMatchException: The current request for action 'index' on controller type 'CategoryController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Index() on type Onclickmuseum.Controllers.CategoryController System.Web.Mvc.ActionResult Index(Onclickmuseum.Models.CategoryModel) on type Onclickmuseum.Controllers.CategoryController]
System.Web.Mvc.Async.AsyncActionMethodSelector.FindAction(ControllerContext controllerContext, String actionName) +276
System.Web.Mvc.Async.ReflectedAsyncControllerDescriptor.FindAction(ControllerContext controllerContext, String actionName) +181
System.Web.Mvc.ControllerActionInvoker.FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, String actionName) +52
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +295
System.Web.Mvc.<>c_DisplayClass1d.b_17(AsyncCallback asyncCallback, Object asyncState) +83
System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +161

Upvotes: 0

Views: 1202

Answers (2)

Saravana
Saravana

Reputation: 40534

It means that MVC found two action methods with the same name and is confused. You can remove the ambiguity by:

Adding a HTTP method attribute:

[HttpGet] // This method will be called only on GET http requests
public ActionResult Index() { ... }

[HttpPost] // This method will be called only on POST http requests
public ActionResult Index(int id) { ... }

Specifying an action name:

// This method will be called for /ControllerName/Index requests
public ActionResult Index() { ... }

[ActionName("Index2")] // This method will be called for /ControllerName/Index2 requests
public ActionResult Index(int id) { ... }

Upvotes: 0

santosh singh
santosh singh

Reputation: 28642

The error you are getting tells that ASP.NET MVC has found two actions with the same name and can't chose which to use.

Upvotes: 1

Related Questions