Похоже, что есть блог Определение текущего уровня доверия в asp.net , который выглядит многообещающе.Я вставил сюда код на случай, если блог умрет.
// Here is a sample code that returns the current trust level, assuming this
// code (or the calling code up the stack), is not loaded from GAC:
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;
}
// The result can be cached in a static field
// for the duration of the app domain lifetime.