c# – 如何将多个参数传递给web api
发布时间:2020-12-16 02:00:14 所属栏目:百科 来源:网络整理
导读:我正在使用小提琴手测试我的请求.. 我使用下面的reuest来调用我的web api方法..它工作正常. http://localhost:50079/Import/Test/abcType :Getweb api method: [ActionName("Test")] public bool getconnection(string id) { return true; } 如果我传递多个
我正在使用小提琴手测试我的请求..
我使用下面的reuest来调用我的web api方法..它工作正常. http://localhost:50079/Import/Test/abc Type :Get web api method: [ActionName("Test")] public bool getconnection(string id) { return true; } 如果我传递多个参数我收到错误:HTTP / 1.1 404 Not Found 我用过: http://localhost:50079/Import/Test/abc/cde Type :Get web api method: [ActionName("Test")] public bool getconnection(string id,string value) { return true; } 我不想使用任何路线…让我知道为什么如果我传递多个参数为什么它不被识别.. 解决方法
您必须指定匹配的路线
config.Routes.MapHttpRoute( name: "TestRoute",routeTemplate: "api/{controller}/{id}/{value}",defaults: new { id = RouteParameter.Optional,value = RouteParameter.Optional } ); 试试以上 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |