0
votes

IDE: Visual Studio 2017

Project: Web Application

WebApiConfig.cs

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

Here is the Get action in Streets controller, which is the only action modified. Other actions are not changed. The controller is scaffold as Web API 2 Controller with read, write actions.

// GET: api/Streets
public DataPack Get()
{
    DataPack pack = new DataPack();

    ...

    return pack;
}

Tool: Postman

Method: GET

Uri: api/Streets

Status: 404 Not Found

Message: "No HTTP resource was found that matches the request URI 'http://localhost:50166/api/Streets'."

MessageDetail: "No route providing a controller name was found to match request URI 'http://localhost:50166/api/Streets'"

Please let me know if there's any mistake.

1

1 Answers

1
votes

You made a mistake in the route declaration, it should be

defaults: new
{
    controller = "Streets", //you wrote controler
    id = RouteParameter.Optional,
 }