href with Submit in Asp.net core MVC

0

I have a _LoginPartial view where you have a link to EXIT (Log out of the 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 it type="submit" and trigger to 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>
    
asked by anonymous 18.02.2018 / 20:09

1 answer

0

As you just want to exit the system, there is no need for a submit, just put the href pointing to your method, eg

View

 <a href="~/Login/Logout" role="menuitem">
     <i class="icon wb-power" aria-hidden="true"></i> Sair
 </a>  

Controller

public class LoginController : Controller
{
    public ActionResult Logout()
    {      
        //retorna para a pagina inicial
    }
}
    
18.02.2018 / 21:47