locked
Authorize returns wrong URL with Localization RRS feed

  • Question

  • User991566988 posted

    Hi

    I've followed this tutorial to apply multi-languages for my asp.net core mvc app. successfully:

    https://medium.com/swlh/step-by-step-tutorial-to-build-multi-cultural-asp-net-core-web-app-3fac9a960c43

    I'm putting '[Authorize]' for some Create method to obligate the user to log in before going to the view.

    But when pressing the link of that view in shared _layout view, it appends the language letters to the URL like \en\ for English language which cause wrong missing view, This doesn't happen if the user is logged in.

    There is no route-culture tag inside the <li> tag for Log in view:

                                @*asp-route-culture="@culture"*@
                                <a asp-area="Identity" asp-page="/Account/Login" class="w-nav-link nav-link text-white" localize-content>Log in</a>

    The same for Register view.

    Why? and How to solve please?

    Saturday, January 2, 2021 12:20 PM

Answers

  • User1312693872 posted

    Hi,musbah7

    musbah7@hotmail.com

    But when pressing the link of that view in shared _layout view, it appends the language letters to the URL like \en\ for English language which cause wrong missing view, This doesn't happen if the user is logged in.

    When the user is not logged in and then click the link of that view in shared _layout view, will he be redirected to the other page?

    If so, if you mean that the page will not be generated, you should check the route of that page.

    And the razor pages does note support [Autherize] at the handler level, what do you mean about putting '[Authorize]' for some Create method?

    If the problem still exists, could you please share more related code for us to reproduce it?

    Best Regards,

    Jerry Cai

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 4, 2021 5:30 AM