0

I have an ASP.NET web api that was created with Entity framework.I added my controller in the controller's folder and it generated the API code for me.but when i run the application it does not show the controller that i added,it only shows the default API page that comes with the application like below.

This is what it displays enter image description here

I would like it to look like this

Expected Output enter image description here

Jasen
  • 14,030
  • 3
  • 51
  • 68
  • What do you expect to see instead ? – Matias Cicero Apr 10 '17 at 18:49
  • Hi @matias-cicero I expect to see my controller there with all the REST calls that are available within my controller. e.g GET : api/contracts/{id} – Tshepiso Selepe Apr 10 '17 at 19:03
  • Is your controller inheriting from the ApiController? – Matt Spinks Apr 10 '17 at 19:06
  • See [this question](http://stackoverflow.com/questions/24284413/webapi-help-page-description) and the [docs](https://learn.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages). And show us the controller code. – Jasen Apr 10 '17 at 19:16
  • Hi selepe , please share WebApiConfig class , – Ranjith Murthy Apr 10 '17 at 19:17
  • Possible duplicate of [WebApi Help Page Description](http://stackoverflow.com/questions/24284413/webapi-help-page-description) – Jasen Apr 11 '17 at 17:50

1 Answers1

0
public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // Web API routes
            config.MapHttpAttributeRoutes();

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

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

NOTE: Add 'ActionApi' route in WebApiConfig.cs file

B. Go
  • 1,436
  • 4
  • 15
  • 22
Suresh
  • 1
  • While this code snippet might solve the issue and provide some limited, immediate help. A [proper explanation](https://meta.stackexchange.com/q/114762/349538) would greatly improve its long-term value by showing why this is a good solution to the problem and would make it more useful to future readers with other, similar questions. Please consider an [edit] your answer to add some explanation, including the assumptions you’ve made. – ButchMonkey Jan 23 '20 at 17:15