A
A
Andrey2019-10-25 16:54:30
ASP.NET
Andrey, 2019-10-25 16:54:30

How to correctly add dynamic buttons to _Layout.cshtml?

Good afternoon everyone! Please tell a beginner how to do these things correctly:
I added authorization to my test site and wanted to display the Login or Logout buttons on the master page depending on whether the user is authorized or not.
5db2fce1274fc530266440.png
But it seems like connecting the model to the master page is bad. Do through partial representations.
I can’t get out of Metanit, but I can’t find anything on a similar topic there ...
What is in the image is implemented like this:

<ul class="nav navbar-nav">
                    <li><a asp-area="" asp-controller="Home" asp-action="Index">Home</a></li>
                    <li><a asp-area="" asp-controller="Work" asp-action="Index">Отчёт</a></li>
                    <li><a asp-area="" asp-controller="Home" asp-action="About">About</a></li>
                    <li><a asp-area="" asp-controller="User" asp-action="Index">Пользователи</a></li>                    
                    <ui class="nav navbar-nav navbar-right">                       
                        <li><a asp-area="" asp-controller="Account" asp-action="Logout"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
                        @{await Html.RenderPartialAsync("_LoginBtn"); }
                    </ui>
                </ul>

I would love to read whatever you send me!
I would be just as happy if you “throw” in words how such things are generally done.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail, 2019-10-25
@makarychev13

Can't get off Metanit

Wow, this is a bad site.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question