5.class="System.Security.Permissions.FileIOPermission,mscorlib,类=“System.Security.Permissions.FileIOPermission,MSCORLIB
6.Version=2.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089"版本=2.0.0.0,文化=中性公钥=b77a5c561934e089“
7.Unrestricted="true"/>无限制=“TRUE”/>
YoucanpassanumberofassembliestothePermCalctoolatthesametime,asshowninthefollowingcommandexample.您可以通过一些程序集PermCalc工具在同一时间,在下面的命令示例所示。
permcalc-Showpermcalc显示
NoteIfanyresourceisaccesseddirectlyfroman.aspxpage,youwillneedtomanuallycalculatethepermissionrequirementsforthatresource.注意:
如果任何资源。
aspx页面直接访问,您将需要手动计算该资源的权限要求。
PermCalcworksonlywithassemblies.PermCalc工程与集会。
Step2.第2步。
ChooseanAppropriateTrustLevel选择适当的信任级别
Trytoevaluatewhetherthepermissionsrequiredforyourapplicationmatchthoseprovidedbyanyofthestandardtrustlevels.尝试评估为您的应用程序所需的权限是否匹配任何标准的信任级别提供的。
TrustLevelsSummary信托级别摘要
ThecapabilitiesavailabletoapplicationsrunningatthevarioustrustlevelsaresummarizedinTable1.表1总结了在不同的信任级别运行的应用程序的能力。
Table1.表1。
TrustLevelsandTheirKeyCapabilitiesandRestrictions信托水平和他们的关键功能和限制
TrustLevel信任级别
KeyCapabilitiesandRestrictions关键功能和限制
Full全
Norestrictionsimposedbycodeaccesssecurity.没有限制代码访问安全性。
High高
Nounmanagedcode.没有非托管代码。
Noenterpriseservices.没有企业的服务。
CanaccessMicrosoftSQLServerandotherOLEDBdatasources.可以访问MicrosoftSQLServer和其他OLEDB数据源。
Cansende-mailbyusingSMTPservers.可以使用SMTP服务器发送电子邮件。
Verylimitedreflectionpermissions.非常有限的反射权限。
Noabilitytoinvokecodebyusingreflection.没有能力通过使用反射调用代码。
Abroadsetofotherframeworkfeaturesareavailable.提供一套广泛的框架功能。
Applicationshavefullaccesstothefilesystemandtosockets.应用有充分的访问文件系统和插座。
Medium中等
Permissionsarelimitedtowhattheapplicationcanaccesswithinthedirectorystructureoftheapplication.权限是有限的应用程序可以访问的应用程序目录结构内。
Nofileaccessispermittedoutsideoftheapplication'svirtualdirectoryhierarchy.没有文件允许访问应用程序的虚拟目录层次结构之外。
CanaccessSQLServer.可以访问SQLServer。
Cansende-mailbyusingSMTPservers.可以使用SMTP服务器发送电子邮件。
Limitedrightstocertaincommonenvironmentvariables.某些共同的环境变量的有限权利。
Noreflectionpermissionswhatsoever.没有反射任何权限。
Nosocketspermission.没有插座的权限。
ToaccessWebresources,youmustexplicitlyaddendpointURLs—eitherintheoriginUrlattributeoftheelementorinsidethepolicyfile.访问Web资源,你必须明确地加入端点URLoriginUrl属性<信任>元素或内部的政策文件。
Low低
Intendedtomodeltheconceptofaread-onlyapplicationwithnonetworkconnectivity.模型与没有网络连接的只读应用程序的概念。
ReadonlyaccessforfileI/Owithintheapplication'svirtualdirectorystructure.只读文件访问的I/O在应用程序的虚拟目录结构。
Minimal最小
Executeonly.只执行。
NoabilitytochangetheIPrincipalonathreadorontheHttpContext.没有能力改变一个线程的HttpContext的IPrincipal。
Ifyourapplicationcallsunmanagedcode,itmustrunwithFulltrust.如果您的应用程序调用非托管代码,它必须运行的完全信任。
Eventheleastrestrictivepartialtrustlevel,High,doesnotpermitcallstounmanagedcode.即使是限制最少的部分信任的水平,高,不允许调用非托管代码。
Tochooseanappropriatetrustlevel要选择一个合适的的信任级别
1.Examineeachtrustlevel,beginningwithHightrust.检查每个信任级别,高信任的开始。
2.LookinsidetheHightrustpolicyfile,web_HighTrust.config.往里高信任的政策文件,web_HighTrust.config。
3.IfyourapplicationrequiresfewercodeaccesssecuritypermissionsthanthoseprovidedbytheHightrustlevel,moveontoconsiderMediumtrust.如果应用程序需要比高信任级别提供的代码访问安全权限少,考虑中等信任。
4.Repeattheprocess,movingfromMediumtoLowtoMinimal,andkeepevaluatingthepartialtrustlevelsuntilyoureachanexactmatchtoyourapplication'srequirementsoruntilyourapplication'srequiredpermissionsslightlyexceedapartialtrustlevel.重复这个过程中,由中等至低到最小,并保持评估的部分信任的水平,直到到达一个完全匹配您的应用程序的要求,或您的应用程序所需的权限,直到略超过部分信任水平。
Thisprocesswillhelpyoutoidentifyatrustlevelthatmatchesyourapplication'scodeaccesssecuritypermissionrequirementsascloselyaspossiblebutdoesnotgrantpermissionsthatyourapplicationdoesnotneed.这一过程将帮助您识别匹配您的应用程序的代码访问安全权限要求尽可能接近但不授予权限,您的应用程序并不需要的信任级别。
Step3.第3步。
ConfigureYourASP.NETApplication配置您的ASP.NET应用程序
YoucanconfigureyourASP.NETapplicationtouseastandardtrustleveleitherinyourapplication'sWeb.configfileorinthemachine-levelWeb.configfile.你可以配置你的ASP.NET应用程序在您的应用程序的Web.config文件中或在计算机级别的Web.config文件中使用标准的信任级别。
Machine-levelconfigurationaffectsalltheASP.NETWebapplicationsandWebserviceshostedonthatserver.机级别的配置影响到所有的ASP.NETWeb应用程序和Web服务的服务器上宿主。
Application-levelconfigurationaffectsonlyaspecifica