我有兩個動作,每當我明確調用第二個動作時,第一個動作仍然被調用。我需要能夠在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