ASP.NET帮助页面的默认主页? [英] ASP.NET Help Pages default home page?

查看:378
本文介绍了ASP.NET帮助页面的默认主页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想去 HTTP:// MYSERVER 并能够得到帮助页面的默认主页,所以第一件事作客 HTTP:// MYSERVER 应该看到的是帮助页

I want to go to http://myserver and be able to get Help Pages as the default home page, so the first thing a guest to http://myserver should see is the Help Page.

我已经建立了这样一条默认路由:

I have a default route set up like this:

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

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
}

然后我有我的帮助页面区登记设立这样的:

Then I have my Help Page Area registration set up like this:

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

    HelpPageConfig.Register(GlobalConfiguration.Configuration);
}

当我改变RouteConfig的控制器帮助我得到:

When I change RouteConfig's controller to "Help" I get:

视图索引或它的主人没有被发现或没有视图引擎
  支持搜索地点

The view 'Index' or its master was not found or no view engine supports the searched locations

当我更改帮助页面路线{控制器} / {行动} / {} apiId我AttributeRoutes停止工作。

When I change Help Page route to "{controller}/{action}/{apiId}" my AttributeRoutes stop working.

有一些简单的方法来让ASP.NET帮助页面的默认主页?

Is there some easy way to make ASP.NET Help Pages default home page?

推荐答案

我用下面的RouteConfig做到了这一点。我也使用ASP.Net帮助页面自动生成从内联XML注释我的文档:

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" });
    }
}

我还要提到的是,我没有任何其他的在这个类的路由,因为我使用的属性路由上的API方法分别。

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.

这篇关于ASP.NET帮助页面的默认主页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆