Get ASP.NET Trust Level

Is there an API to get the current ASP.NET trust level?

+16
Jun 30 '09 at 15:18
source share
2 answers

From the dmitryr blog :

AspNetHostingPermissionLevel GetCurrentTrustLevel() { foreach (AspNetHostingPermissionLevel trustLevel in new AspNetHostingPermissionLevel [] { AspNetHostingPermissionLevel.Unrestricted, AspNetHostingPermissionLevel.High, AspNetHostingPermissionLevel.Medium, AspNetHostingPermissionLevel.Low, AspNetHostingPermissionLevel.Minimal } ) { try { new AspNetHostingPermission(trustLevel).Demand(); } catch (System.Security.SecurityException ) { continue; } return trustLevel; } return AspNetHostingPermissionLevel.None; } 
+22
Jun 30 '09 at 15:22
source share

The following code gets the ASP.NET Trust Level program layer using the official configuration API:

 using System.Web; using System.Web.Configuration; ... var trust = WebConfigurationManager.GetSection("system.web/trust") as TrustSection; return trust.Level; 
0
Sep 14 '15 at 15:39
source share



All Articles