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.

Recommended Answers

Is there any InnerException by any chance?

Jump to Post

All 2 Replies

Is there any InnerException by any chance?

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()
Be a part of the DaniWeb community

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