是否有API来获取当前的ASP.NET信任级别?
来自dmitryr的博客:
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; }