Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Public action method was not found on controller

I have the following controller method:

public ActionResult GetResults(string viewToReturn, int resultsPerPage, 
          string classification = null, string sessionId = null, int? lastId= null)
{
               ...
}

Calling the method above via the following url:

http://localhost:63455/Home/GetResults?viewToReturn=grid&resultsPerPage=30

results in an exception thrown with this message:

A public action method 'GetResults' was not found on controller 'MyWebSite.Controllers.HomeController'.

and here is the RegisterRoutes:

......    
routes.MapRoute("Home", "home/{action}/{*qualifier}",
       new { controller = "Home", action = "Index", qualifier = UrlParameter.Optional });
......
routes.MapRoute("SearchTitle", "{*path}",
       new { controller = "Home", action = "SearchTitle", path = UrlParameter.Optional });

Why am I getting this error and how do I fix it? Thanks!

like image 304
Barka Avatar asked May 20 '13 20:05

Barka


1 Answers

I had the [HttpPost] attribute on the method. I could swear that I removed it earlier, but somehow after I took a break and came back, I saw it. After removing it, everything now works fine.

like image 100
Barka Avatar answered Oct 06 '22 00:10

Barka