我有两个动作,每当我明确调用第二个动作时,第一个动作仍然被调用。我需要能够在mysite.com/api/Awesome/GetSomeExamples写,没有它总是引发GetAllClasses路由,击中错误的动作
public class AwesomeController : Controller
{
public IEnumerable<myClass> GetAllClasses()
{
//...some stuff
}
public IEnumerable<string> GetSomeExamples()
{
//...some stuff
}
//... also have some more actions which take in one parameter
}
我的路由是这样的,但没有工作
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "ActionApi",
url: "api/{controller}/{action}/{id}",
defaults: new { id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
错误我得到:找到与请求匹配的多个操作
您指定的路由是正确的。您可能在内部从一种方法到另一种方法调用该方法。请检查GetSomeExamples中的代码。 – Kenneth 2013-05-08 13:51:41
我确实在JavaScript中调用了它,但只在某个页面上,我删除了(只是incase),但我仍然收到此错误: 发现多个匹配请求的操作 – datatest 2013-05-08 14:00:08