WebApi HelpPage api detail page 404, when "api" prefix removed?

40 Views Asked by At

.net4.7 + WebApi5.23 + HelpPage5.23.

My WebApiConfig.Register:

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        ...

        config.MapHttpAttributeRoutes();

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

And the index page is worked: enter image description here

But the api detail page fail(Page not found): enter image description here

Please help, thank you.

1

There are 1 best solutions below

0
On

Routing is bound to be getting confused between routing to your MVC controller or your WebApi controller since the are now sharing the same path.

If you need a web page to show, create a new method within the HelpController that returns a new view.

If you need Json returned, you can still create a new method within the HelpController to do that, just change the return type to JsonResult.

Hopefully this gives you enough to understand what's going wrong, and therefore what to google next.