不能调用REST函数
本文关键字:函数 REST 调用 不能 | 更新日期: 2023-09-27 18:17:02
我有一个WCF服务,我在我的web api MVC应用程序中使用的功能。我遇到的错误是:
"No action was found on the controller that matches the request"
如果我之前的函数不起作用,问题不会那么奇怪,但它们确实起作用了。这是我的代码…
[ActionName("restfunctionname")]
public SortedList<string, PropertyClass> REST_Function([ModelBinder(typeof (CommaDelimitedArrayModelBinder))] string[] parameterList, string parameter2, string parameter3)
{
WCF wcfService = new WCF();
List<string> arrayParameter = new List<string>();
ids.AddRange(parameterList);
SortedList<string, PropertyClass> returnValue = wcfService.GetTranslationsFromId(arrayParameter, paremeter2, parameter3);
return returnValue;
}
返回值应该是SortedList
因为我在MVC,在我的WebApiConfig我设置这个:
config.Routes.MapHttpRoute(
name: "restfunctionname",
routeTemplate: "api/{controller}/{action}/{parameterList}/{parameter2}/{parameter3}",
defaults: new { parameterList= RouteParameter.Optional, parameter2 = RouteParameter.Optional, parameter3 = RouteParameter.Optional }
);
最后,我从浏览器调用我的函数,试图在响应体中捕获JSON,像这样:
http://localhost:20915/api/controller/restfunction/firstItemOfArray,SecondItemOfArray/parameter2/parameter3
…但是什么都没有。我错过什么了吗?
谢谢。
我没有词"GET"在我的WCF函数,例如…我原来的WCF函数名称是:TranslationFromID,然后我把它改为:GetTranslationFromID,现在它工作了