0

I have an MVC4 project with many controllers. I added an Api controller called BatchDetailsController in the root directory of the project.

I also created a WebApiConfig class as below

 public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.

            // Web API routes
            config.MapHttpAttributeRoutes();

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

I also invoke the above register method from global.asax as

  WebApiConfig.Register(GlobalConfiguration.Configuration);

in Application_Start

Now I have tried to access the controller by using then Urls /BatchDetails /api/BatchDetails /BatchDetails/Get /api/BatchDetails/Get

All of them return 404

What is the URL I need to use in this case

josephj1989
  • 9,509
  • 9
  • 48
  • 70

1 Answers1

0

for example when using visual studio to debug/host the project the url would be http://localhost:port/api/BatchDetals/{method}

Right click on the project and see if IIS express is selected and note the port number. The project should come up via run/f5 in visual studio at the Project URL.

If not I would re-install IIS8 express.

Visual Studio Project Settings

Mike Beeler
  • 4,081
  • 2
  • 29
  • 44