So I have this Controller:
namespace MyNamespace.Controllers
{
[Authorize(Roles="Administrator")]
public class MyController : Controller
public ActionResult Index()
{
...
As you can see, only users with the Administrator role have access to MyController's Action methods.
So, from somewhere else (another controller, another class in my library class, etc) how do I check if Current.User.Identity.Name has access to MyController?
Something that works like "UrlAuthorizationModule.CheckUrlAccessForPrincipal" for WebForms.
You would have to read the information from the other controller. This can be done by instantiating its context and the Descriptor, then instantiating the
AuthorizationContext
for that controller and read the filter info.This is how you can do it