0

I have a Web API with 2 Controllers: ValuesController and MyController

I initially created ValuesController and I access it using MyUrl/api/values, this works fine.

I then added another controller MyController and in the comments that were generated by Visual Studio, it says that I access it using api/. When I try api/MyController, it doesn't work, I get a page that reads No HTTP resource was found that matches the request URI '/api/MyController'.

My WebApiConfig looks like this:

public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );


        }
    }

How do I access the GET in my new controller? Do I need to modify the WebApiConfig?

Thanks in advance for any help.

1 Answer 1

3

If the controller-class is actually named "MyController", then the URL that points to it should be:

/api/My

not:

/api/MyController
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.