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.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
A Bogus
  • 3,852
  • 11
  • 39
  • 58

1 Answers1

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);
    }
Community
  • 1
  • 1
Parrybird
  • 800
  • 11
  • 18