I am getting this error after trying to implement paging support.
I am on this step of the html tutorial: http://nerddinnerbook.s3.amazonaws.com/Part8.htm
I am getting this error after trying to implement paging support.
I am on this step of the html tutorial: http://nerddinnerbook.s3.amazonaws.com/Part8.htm
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.
If you have two Index-actions in your DinnersController.cs
:
public ActionResult Index() {
and:
public ActionResult Index(int? page) {
Then you should remove the first Action. since the second is the 'updated' version of the first. The second Action accepts requests to:
/Dinners
/Dinners?page=2
/Dinners/Index
/Dinners/Index?page=2
And with the change in RegisterRoutes it also accepts requests to:
/Dinners/Page/2
You can have two Actions with the same name, providing one is for saving (postbacks), where you decorate the saving action with [AcceptVerbs(HttpVerbs.Post)]
or just [HttpPost]
MVC does not support overloading of action methods in your controller. It is not possible to have two Index() actions with different method signatures on the same controller.
In order to make the example you are testing work, you must remove the Index() action which does not accept any parameters, and replace it with the action that takes a nullable int as a parameter.