2

I am getting next message on my WebApi controller request:

Message: "The requested resource does not support http method 'GET'."

My action:

[HttpGet]
[System.Web.Http.AcceptVerbs("GET")]
public EntityDTO Get(long entityId)
{


    return new Entity();
}

As you see, it already as AcceptVerbs and GET attributes.

My route in WebApiConfig:

config.Routes.MapHttpRoute(
     name: "EntityRoute",
     routeTemplate: "api/entity/{id}/{controller}",
     defaults: new { id = RouteParameter.Optional, controller = "Entity" }
);

This route fires for sure, I know it because my controller's Constructor fires.

Any ideas?

PS. There are lots of similar issues on StackOverflow, but for those issues adding proper attribute usually helped.

1 Answer 1

3

The id parameter in your route does not match entityId in your method. They need to match.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! xD It just was a looong day for me) To tired to notice such thing Silly me)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.