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.

Is there any InnerException by any chance?

No. InnerException is also null.

Here's what I get:

System.Security.SecurityException occurred
  HResult=-2146233078
  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]'.
  Source=System.IdentityModel.Services
  StackTrace:
       bij System.IdentityModel.Services.ClaimsPrincipalPermission.Demand()
  InnerException: 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.