4

I have a ASP.NET Core Web API project, and the following controller:

[Route("/api/v0.1/controller")]
[ApiController]
public class MyController : ControllerBase
{
   [HttpGet("/test")]
   public ActionResult Test() { return null; }
}

but when I run the project, at /api/v0.1/controller/test I get "page not found" and I don't see where I made a mistake.

0

1 Answer 1

6

Your method route template contains prefixed /, due to that, the app route couldn't find the appropriate path.

Modify test method route template as follows.

[HttpGet("test")]
public ActionResult Test() { return null; }  

More at Routing to controller actions in ASP.NET Core

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

Comments

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.