Posted on: 4/3/2015 9:01:18 AM | Views : 717

Hi!
I have a simple web api controller that i want to secure with claims authorization:

[ClaimsPrincipalPermission(SecurityAction.Demand, Operation = "Get", Resource = "Contacts")] public IHttpActionResult Get() { return Ok("Some contacts.."); }
I am not sure how to handle security exceptions with attributes filter, i've tried something like this:

public class SecurityExeceptionFilterAttribute : ExceptionFilterAttribute { public override void OnException(HttpActionExecutedContext actionExecutedContext) { if (actionExecutedContext.Exception is SecurityException) { actionExecutedContext.Response.StatusCode = System.Net.HttpStatusCode.Unauthorized; actionExecutedContext.Response.Headers.Add(" ...

Go to the complete details ...