Search code examples
c#asp.net-mvc.net-corerazor-pages

How to specify specific controller from View


I'm using the .net core MVC app. If I don't indicate asp-controller="DealController" then the action goes to UserController, because the call happens from user.cshtml. But when I specify a specific Controller, the call still does not go to the DealController. Please tell me what I'm doing wrong.

 <form asp-route-empname="@deal.Id" asp-controller="DealController" asp-action="DeleteDeal" method="post">
    <button type="submit">Delete</button>
    </form>

Solution

  • Remove the "Controller" part of the controller name:

    <form asp-route-empname="@deal.Id" asp-controller="Deal" asp-action="DeleteDeal" method="post">