0

Here's the routing config for ASP.NET Core 2.0 app:

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

And here's some page markup (_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>

And suppose I start my browser with this Url - http://localhost/operator.

My Login links rendered like - https://localhost:44396/operator/session/signin

Why not https://localhost:44396/session/signin ? How can I make them 'absolute'? I also tried:

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

What am I missing?

AlexB
  • 4,167
  • 4
  • 45
  • 117
  • How did you set up your authentication logic to do the redirect from /operator to the sign in screen? – David Liang Oct 19 '17 at 23:34
  • I believe it's irrelevant here but I use Azure AD B2C. You can find B2C samples for .NET Core 2.0 – AlexB Oct 19 '17 at 23:42
  • Oh you meant the signup link is rendered incorrectly. I thought you meant when you start the app from /operator, it redirects to /operator/session/signin, which is supposed to be just /session/signin. – David Liang Oct 19 '17 at 23:52
  • correct. I wonder if I described the question straightforward. – AlexB Oct 19 '17 at 23:54
  • I created a project with your routing setup and the links are rendered correctly for me. Is `operator` an area? – David Liang Oct 19 '17 at 23:57
  • No. But this html is from `_LoginPartial.cshtml`which is in turn part of `_Layout.cshtml`. – AlexB Oct 21 '17 at 01:08
  • `What am I missing?` - You are missing the rest of your routing configuration. Clearly the URL that is being generated is matching a route which you have not posted. The ***first*** match always wins, so if you have a route before your intended one that is matching, your intended route will never be reached. That said, please post the rest of your routes. – NightOwl888 Oct 23 '17 at 23:55

0 Answers0