I have a view that shows users in the system, including user's status. I need to add a button for each record, this button should pass the user ID for a function in the controller, and this function should've change the value of user's status so if the status is true then it should be changed to false.
The problem here is the button I've added is not calling the function. I need to know why ...
Controller
[HttpPost]
public async Task<IActionResult> Change(string userid)
{
var user = await _userManager.FindByIdAsync(userid);
user.Status = !user.Status;
await _userManager.UpdateAsync(user);
return View();
}
View
<input type="button" asp-controller="Users" asp-action="Change"
asp-route-userid="@user.Id" value="Activate/De Activate" />
Many thanks
GETcall - not aPOST- but your controller's method is annotated with the[HttpPost], so it will only respond toPOSTrequests.....