ASP.NET Help Pages default home page?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 22:59:33

I accomplished this with the following RouteConfig. I am also using ASP.Net Help Pages to auto-generate my documentation from the inline XML comments:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        // By default route the user to the Help area if accessing the base URI.
        routes.MapRoute(
            "Help Area",
            "",
            new { controller = "Help", action = "Index" }
        ).DataTokens = new RouteValueDictionary(new { area = "HelpPage" });
    }
}

I should also mention that I don't have any other routing in this class since I am using Attribute Routing on API methods individually.

For those who search where to add the route, with the current version of the WebApi and of the NuGet package you have to search for the file named "HelpPageAreaRegistration" in the Area folder added by NuGet.

Here is mine once it was coded to have the help page with WebApi has default web page.

public class HelpPageAreaRegistration : AreaRegistration
{
    public override string AreaName
    {
        get
        {
            return "HelpPage";
        }
    }

    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);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!