0

I can't figure out how to write the method signature for a REST(ish) AJAX call in Aspnet WebAPI.
My route is recognised but I get a "No HTTP resource was found that matches the request URI..."

I try to do a REST(ish) call like

http://mysite.com/api/Project/42/Children

and my idea is to have the server return all children of project 42.

My route is:

config.Routes.MapHttpRoute(
    name: "DefaultApiWithAction",
    routeTemplate: "api/{controller}/{id}/Children",
    defaults: new { action="Children"}
);

and my method signature is:

public class ProjectController : ApiController {
    [HttpGet]
    public IEnumerable<Project> Children(int projectID) {
    ...

Why isn't my method recognised?
I am also not sure I am doing the right "restish" thing here.

4

1 回答 1

1

将您的操作参数名称从“proejctID”修改为“id”

公共 IEnumerable Children(int id )

于 2013-05-10T21:29:47.930 回答