有人可以帮忙吗?我有这个控制器:
public class CbpOutcomeController : ApiController
{
// POST /api/CbpOutcome/1/
public HttpResponseMessage PostCreateCbpOutcome(CbpOutcome co)
{
... snip ...
return resp_msg;
}
}
而这条路线:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"HubProfilePostRoute", // Route name
"hub/{controller}/{action}", // URL with parameters
new { controller = "Home", action = "Index" } // Parameter defaults
);
routes.MapHttpRoute(
name: "ProfileByRegionApi",
routeTemplate: "api/{controller}/Region/{region_name}"
);
routes.MapHttpRoute(
name: "ProfileByGlobalPriorityApi",
routeTemplate: "api/{controller}/GlobalPriority/{priority_name}"
);
routes.MapHttpRoute(
name: "ApiRoute",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
当我使用这个 JSON 结构进行POST
to时:http://localhost:2515/api/CpbOutcome
{ "Id":0, "Description":"This is a description", "DisplayOrder": 3,
"ModifiedBy":"Somebody's name here", "Cbp": { "Id": 163 }}
我收到这条消息:
No type was found that matches the controller named 'CpbOutcome'.