I'm implementing a website using asp.net MVC. I'm trying assign role to user by clicking into the role. I've tried several ways, unfortunately, I failed.

Controller method

[HttpPost,ActionName("AssignUserToRole")]
[ValidateAntiForgeryToken]
[CustomAuthorize(Roles ="SudoAdmin")]
public ActionResult AssignUserToRole(long userId, long roleId)
{
    new BusinessUser().AddRoleToUser(userId, roleId);

      return RedirectToAction("Index");
}

view

 @Html.ActionLink(@r.RoleName, "AssignUserToRole", "Users", new { userId = Model.UserId, roleId = r.RoleId })

first I tried Jquery Ajax, but it failed, even though I think it was not a very great idea. However, I still would like to do it with "Ajax"I mean without refreshing the page.

I hope my question is good enough thanks for all of you

Related posts

Recent Viewed