这是由ASP.NET安全性引发的异常,有可能的缘由是部署服务器上的machine.config或web.config中配置的安全策略被修改过。
在.net2.0中,Asp.Net默认在C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config中配置了网站的信任级别:
<securityPolicy>
<trustLevel name="Full" policyFile="internal"/>
<trustLevel name="High" policyFile="web_hightrust.config"/>
<trustLevel name="Medium" policyFile="web_mediumtrust.config"/>
<trustLevel name="Low" policyFile="web_lowtrust.config"/>
<trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>
</securityPolicy>
<trust level="Full" originUrl=""/>
原本默认是Full级别,但可能服务器供应商出于安全考虑而采用了其余策略。
当前有一种办法,就是在你网站根目录下的web.config中从新声明所选用的策略为Full:
<trust level="Full" originUrl="www.xggsb.com"/
它在配置文件中的层次结构以下:
<location allowOverride="true">
<system.web>
<trust level="Full" originUrl="www.szssgs.com"/>
</system.web>
</location>
location是根元素。
web
添加信任.net
<location path="minlingzhi123" allowOverride="false">
<system.web>
<securityPolicy>
<trustLevel name="Full" policyFile="internal" />
</securityPolicy>
<trust level="Full" originUrl="" />
<identity impersonate="true" />
</system.web>
</location>
安全