I have the following method:

[ClaimsPrincipalPermission(SecurityAction.Demand, Resource = "Order", Operation = "Place")]
public string PlaceNewOrder() { }

When the AuthorizationContext.Principal does not have the required Claims, a SecurityException is thrown (as expected). Unfortunately, all the properties of this exception (such as Action or Demanded) are null.

Is there a way to get to the attribute information from the exception? It would be nice if you can show the user which specific claim caused the failure.

No. InnerException is also null.

Here's what I get:

System.Security.SecurityException occurred
  Message=ID4266: De aanvraag voor ClaimsPrincipalPermission is mislukt voor: 
  Actie: 'System.Collections.ObjectModel.Collection`1[System.Security.Claims.Claim]', 
  Resource: 'System.Collections.ObjectModel.Collection`1[System.Security.Claims.Claim]'.
       bij System.IdentityModel.Services.ClaimsPrincipalPermission.Demand()
This article has been dead for over six months. Start a new discussion instead.