我有两个动作,每当我明确地调用第二个时,第一个仍然会被调用。我需要能够在 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 }
);
}
我得到的错误:找到与请求匹配的多个操作