2009-06-30 14 views

Odpowiedz

22

Od dmitryr's 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; 
} 
0

Poniższy kod uzyskać prąd ASP.NET Poziom zaufania programowo przy użyciu oficjalnego API konfiguracji:

using System.Web; 
using System.Web.Configuration; 

... 

var trust = WebConfigurationManager.GetSection("system.web/trust") as TrustSection; 
return trust.Level; 
+0

Było więc oczywiste, przepraszam. –

Powiązane problemy