Setting Help Page as default route
Asked Answered
H

1

5

I have a C# .Net 4.5 Web Api application to which I have added a Help Page such as the one shown here.

When a developer launches the Web Api application in Visual Studio, I would like the help page to come up.

I would like to accomplish this by the using routing (such as a change to WebApiConfig.cs or Global.asax.cs) as opposed to a setting in the project's properties.

In the WebApiConfig.cs file I tried adding the following -

config.Routes.MapHttpRoute("Default", "api/help");

That did not work. Does anyone know how to make this work? Thanks.

Hoye answered 13/3, 2015 at 18:4 Comment(1)
How exactly it doesn't work? What is shown instead?Implacable
P
7

Two years late, but for the benefit of Googlers like myself - A way to do it (based on this answer) is simply to modify the RegisterArea method in the HelpPageAreaRegistration.cs class in the HelpPage Area to contain a blank route. Example -

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "HelpPage_Default",
            "Help/{action}/{apiId}",
            new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });
        context.MapRoute(
            "Help Area",
            "",
            new { controller = "Help", action = "Index" });

        HelpPageConfig.Register(GlobalConfiguration.Configuration);
    }
Pelasgian answered 28/4, 2017 at 13:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.