I added the AuthorizeAttribute to secure my ActionResult.
[Authorize(Roles = "MyUser, Admin")]
public ActionResult Index()
{
var allData = myDataRepository.FindAllData();
return View(allData);
}
The Index view displays a list of data from my table. I want to show 1 row is the user Role is MyUser and all rows if the Role is Admin.
Is the correct (MVC) way just checking for the user Role and doing an if else?
I believe you are going to want to include the role limitation to your repository and allow that to determine what data to return.
Hal