Below is code for a simple AuthorizationHandler. In case of failure I want to redirect to a specific Controller/Action. How do I achieve this in ASP.NET 5?
With MVC5 we could do redirects in authorization filters however using policy and authorization handlers seem to be the recommended approach for ASP.NET 5.
public class AdminOnlyRequirement : AuthorizationHandler<AdminOnlyRequirement>, IAuthorizationRequirement { protected override void Handle(AuthorizationContext context, AdminOnlyRequirement requirement) { if (context.User.IsAdmin()) //IsAdmin() is custom extension Method { context.Succeed(requirement); } else { context.Fail(); } } }