0
I have a _Loginpartial view in which you have a link to QUIT (Logout system).
<li role="presentation">
      <a href="javascript:void(0)" role="menuitem">
         <i class="icon wb-power" aria-hidden="true"></i> Sair
      </a>                       
</li>
How do I make him type="submit" and shoot my action asp-action="Logout"?
<form asp-area="" asp-controller="Account" asp-action="Logout" method="post" id="logoutForm" class="navbar-right">
        <ul class="nav navbar-nav navbar-right">
            <li>
                <a asp-area="" asp-controller="Manage" asp-action="Index" title="Manage">Olá @UserManager.GetUserName(User)!</a>
            </li>
            <li class="dropdown">
                <a class="navbar-avatar dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false"
                   data-animation="scale-up" role="button">
                    <span class="avatar avatar-online">
                        <img src="../../assets/portraits/5.jpg" alt="...">
                        <i></i>
                    </span>
                </a>
                <ul class="dropdown-menu" role="menu">
                    <li role="presentation">
                        <a href="javascript:void(0)" role="menuitem"><i class="icon wb-user" aria-hidden="true"></i> Perfil</a>
                    </li>
                    <li role="presentation">
                        <a href="javascript:void(0)" role="menuitem"><i class="icon wb-settings" aria-hidden="true"></i> Configurações</a>
                    </li>
                    <li class="divider" role="presentation"></li>
                    <li role="presentation">
                        <a href="javascript:void(0)" role="menuitem"><i class="icon wb-power" aria-hidden="true"></i> Sair</a>                       
                    </li>
                </ul>
            </li>
        </ul>
 </form>
Hello Cassio!! It gives displays an msg informing that it was not possible to find the page... I checked the route right but will not.
– Master JR
Hello Jalber, so I gave you an example, if you copy my code, you should create the Logout function too, if not, you won’t even find it.
– Cassio Alves
It already exists now! It is in the Account controller: [Httppost] [Route("Account/logout")] [Validateantiforgerytoken] public async Task<Iactionresult> Logout() {
 await _signInManager.SignOutAsync();
 _logger.LogInformation("User logged out.");
 return RedirectToAction(nameof(HomeController.Index), "Home");
 }
– Master JR
and as your href?
– Cassio Alves
<a href="~/Account/logout" role="menuitem"><i class="icon Wb-power" Aria-Hidden="true"></i> Quit</a>
– Master JR
Guy has some error on the route, when you click it goes where? which link appears in the address bar?
– Cassio Alves
https://localhost:44355/home/Account/logout
– Master JR
So that’s the error, put it like this in your href: //Account/logout/
– Cassio Alves
Weird. It doesn’t work....
– Master JR
It’s going the same way?
– Cassio Alves
https://Account/logout/
– Master JR
Exchange href for: Url.Action("logout", "Account")
– Cassio Alves
It still doesn’t work..... If I do so, it works: <button type="Submit" class="btn btn-link navbar-btn navbar-link">Log out</button>
– Master JR
@Jalberromano Your action meets the POST method and you’re using a link (that sends GET)
– Jéf Bueno
@LINQ and how do I post using the same javascript? <a href="javascript:void(0)" role="menuitem"><i class="icon Wb-power" Aria-Hidden="true"></i> Quit</a>
– Master JR
@Jalberromano why you need a post?
– Jéf Bueno
It is that in my model Identity, created by Asp.net core, is created with this standard Automatically. As I’m using a web theme, I need to adapt it.
– Master JR