ASP.NET Core 2.0路由 - 如何拥有正确的绝对路由?

时间:2017-10-19 20:48:18

标签: asp.net-core asp.net-core-2.0 asp.net-routing

这是ASP.NET Core 2.0应用程序的路由配置:

            routes.MapRoute(
                "auth",
                "session/{action}",
                new { controller = "Session" }
            );

            routes.MapRoute(
                "operator",
                "operator/{action}",
                new { controller = "Operator", action = "Index" }
            );

            routes.MapRoute(
                "default",
                "{action=Index}/{id?}",
                new { Controller = "Home" }
            );

这里有一些页面标记(_LoginPartial.cshtml):

<div>

    <a asp-route="auth" asp-route-action="SignIn" class="btn btn-default navbar-btn">
        <span class="glyphicon glyphicon-log-in"></span> Sign in
    </a>
    <a asp-area="" asp-controller="Session" asp-action="SignUp" class="btn btn-default navbar-btn">
        <span class="glyphicon glyphicon-edit"></span> Sign up
    </a>
</div>

假设我使用此Url启动浏览器 - http://localhost/operator

我的登录链接呈现为 - https://localhost:44396/operator/session/signin

为什么不https://localhost:44396/session/signin?我怎样才能让他们'绝对'?我也尝试过:

    <a asp-controller="Session" asp-action="SignIn" class="btn btn-default navbar-btn">
        <span class="glyphicon glyphicon-log-in"></span> Sign in
    </a>

我错过了什么?

0 个答案:

没有答案