這是由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>
安全