Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 4 ASP.NET帮助页默认主页?_Asp.net Mvc 4_Asp.net Mvc Areas_Attributerouting_Asp.net Web Api Helppages - Fatal编程技术网

Asp.net mvc 4 ASP.NET帮助页默认主页?

Asp.net mvc 4 ASP.NET帮助页默认主页?,asp.net-mvc-4,asp.net-mvc-areas,attributerouting,asp.net-web-api-helppages,Asp.net Mvc 4,Asp.net Mvc Areas,Attributerouting,Asp.net Web Api Helppages,我想去http://myserver并且能够将帮助页面作为默认主页,因此客人首先要做的事情是http://myserver应该看到的是帮助页面 我有如下设置的默认路线: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default",

我想去
http://myserver
并且能够将帮助页面作为默认主页,因此客人首先要做的事情是
http://myserver
应该看到的是帮助页面

我有如下设置的默认路线:

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 }
        );
}
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);
}
然后,我的帮助页面区域注册设置如下:

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 }
        );
}
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的
控制器
更改为
“帮助”
时,我得到:

未找到视图“索引”或其主视图,或者没有视图引擎 支持搜索的位置

当我将帮助页面路由更改为
“{controller}/{action}/{apid}”
时,我的属性输出停止工作


有什么简单的方法可以使ASP.NET帮助页面成为默认主页吗?

我通过以下RouteConfig完成了这一点。我还使用ASP.Net帮助页从内联XML注释自动生成文档:

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方法上单独使用属性路由。

对于那些搜索添加路由位置的人,使用当前版本的WebApi和NuGet软件包,您必须搜索名为“HelpPageAreaRegistration”的文件在NuGet添加的区域文件夹中

这里是我的,一旦它被编码为有WebApi的帮助页面有默认网页

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