In the case where the action is conceptually the same, but the display is different, I will have one action and return different views depending on your discriminator. I would go with a second example, slightly modified. Please note that there is no need to receive data if the user is not in the corresponding role.
[Authorize]
public ActionResult List(int? divID, int? subDivID)
{
var view = HttpContext.User.IsInRole("Admin")
? "AdminList"
: (HttpContext.User.IsInRole("Consultant")
? "ConsultantList"
: null);
if (view == null)
{
return View("NotFound");
}
var data = GetListItems(divID.Value, subDivID.Value);
return View( view, data );
}
, , , null Nullable<int>, ?
, , .
public string GetRolePrefix()
{
return HttpContext.User.IsInRole("Admin")
? "Admin"
: (HttpContext.User.IsInRole("Consultant")
? "Consultant"
: null);
}
...
var prefix = GetRolePrefix();
if (prefix == null)
{
return View("NotFound");
}
...get model...
return View( prefix + "List", data );