Asp.net中等安全模式

为了服务器安全,很多国外的Asp.net虚拟主机(比如GoDaddy)都把设置代码执行权限设置为Medium Trust Level,这时候,与Full Trust Level不同,Asp.net程序会有很多限制。如果你正在开发通用的Web产品,比如BBS、Blog、CMS、Portal,那么为了让产品能更大程度适应各种运行环境,你需要考虑到Asp.net中等安全模式的相关问题。

什么是中等安全模式?

Asp.net通过信任级别(Trust Level)设置代码执行权限,默认有5种,分别是:Full、High、Medium、Low、Minimal。虚拟主机提供商通常在系统的machine.config配置了<system.web><trust level=’Medium’ />…

常见异常信息:

Required permissions cannot be acquired. Description: An unhandled exception occurred during the execution of the current web request.Please review the stack trace for more information about the error and where it originated in the code. SecurityException: Request for the permission of type ‘System.Security.Permissions.ReflectionPermission failed或者:System.Security.SecurityException: Request for the permission [...]