Home > Back-end >  asp-action and asp-controller executes post method after reedirects
asp-action and asp-controller executes post method after reedirects

Time:10-24

I use from asp-action in order to logout action as:

<form asp-action="Logoff" asp-controller="Account">
    <button type="submit" >
        <i ></i> 
        Logout
    </button>
</form>

So I want to use the same to redirect to a new view, that view has a inside it and the controller has a HttpPost, so when I click on it executes the post method, is there a way to avoid the execution of HttpPost method and still using asp-actions?

I change the button type to button, but it do anything when it's clicked

CodePudding user response:

You can try to add method="get" into the form,so that when you click on it executes the get request:

<form method="get" asp-action="Logoff" asp-controller="Account">
    <button type="submit" >
        <i ></i> 
        Logout
    </button>
</form>
  • Related