1
votes

I have a controller Foo and an action Bar.
The only route:

routes.MapRoute(
    name: "foo",
    url: "foo",
    defaults: new { controller = "Foo", action = "Bar" }
);

The URL localhost://foo works well;

If i change the route like this:

routes.MapRoute(
    name: "foo",
    url: "api/foo",
    defaults: new { controller = "Foo", action = "Bar" }
);

then localhost://api/foo doesn't work.

WHY? I'm sure there's a question duplication somwhere, but i was unable to find it. Please, advice.

2
do you have any other route definition - Shyju
@Shyju no. I specially created a brand new app and put only this route. - LINQ2Vodka
@Shyju at last i've found the problem. Posted the answer below. - LINQ2Vodka

2 Answers

2
votes

It was my fall.
In the Application_Start of global.asax there's a line:

WebApiConfig.Register(GlobalConfiguration.Configuration)

which overrides my "api" path.