国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

虛擬主機(jī)上asp.net運(yùn)行權(quán)限不足問(wèn)題及解決

2019-11-18 17:06:19
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

   有些時(shí)候我們寫(xiě)的asp.net應(yīng)用程序是運(yùn)行在虛擬主機(jī)上。有一些虛擬主機(jī)可能是由于安全的考慮,對(duì)asp.net做了權(quán)限設(shè)置,會(huì)導(dǎo)致我們的應(yīng)用程序無(wú)法正常運(yùn)行。

問(wèn)題現(xiàn)象:
     由于某種原因,asp.net不能加載某些dll文件,出現(xiàn)如下錯(cuò)誤提示: Server Error in '/' application.
---------------------------------------------

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.

Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:


[PolicyException: Required permissions cannot be acquired.]
   System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +2738293
   System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57

[FileLoadException: Could not load file or assembly 'Microsoft.PRactices.ObjectBuilder, Version=1.0.51205.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
   System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
   System.Reflection.Assembly.Load(String assemblyString) +25
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +32

 


問(wèn)題分析:
    根據(jù)我的觀察,asp.net應(yīng)用程序直接生成的dll可以正常加載,由asp.net直接調(diào)用的外部dll也可以正常加載,但是僅被外部dll引用的其他外部dll不能加載。我的猜想是:由于權(quán)限是不完全的,asp.net應(yīng)用本身生成的dll和直接引用的dll可以通過(guò)權(quán)限的繼承獲得權(quán)限,而僅被外部dll引用的其他外部dll因?yàn)闄?quán)限的限制不能繼承權(quán)限,因此出現(xiàn)了權(quán)限不足的問(wèn)題。

問(wèn)題解決:
    通過(guò)在我電腦的試驗(yàn),推測(cè)虛擬主機(jī)上修改了根web.config(在我電腦上其位置為C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/CONFIG)的設(shè)置.
    默認(rèn)web.config的權(quán)限設(shè)置節(jié)如下:
<location allowOverride="true">
        <system.web>
            <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="" />
        </system.web>
</location>
    推測(cè)虛擬主機(jī)上修改之后的設(shè)置: <location allowOverride="false">
        <system.web>
            <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="High" originUrl="" />
        </system.web>
</location>    他首先設(shè)置了allowOverride為false,這就阻止了在用戶(hù)web.config中重新定義權(quán)限的能力。然后,他定義trust level為High,而不是默認(rèn)的Full。經(jīng)我測(cè)試,只要trust level不為Full,僅被外部dll引用的其他外部dll就不能被加載。 因此,我建議技術(shù)支持將allowOverride節(jié)設(shè)置為true。這樣我就可以在web.config中重新指定權(quán)限了。
例:<trust level="Full" originUrl="" />

    最近已經(jīng)不研究aps.net了,因此也沒(méi)有認(rèn)真去查找深層的原因,或許我的認(rèn)識(shí)還有誤。希望那位高手可以道出深層的原因,或指正我的錯(cuò)誤。


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 莫力| 黎城县| 襄汾县| 灵寿县| 万盛区| 宁河县| 临沧市| 中西区| 拉萨市| 贵阳市| 威海市| 淄博市| 兴化市| 远安县| 监利县| 汶上县| 镇沅| 米脂县| 漳州市| 伊吾县| 鸡东县| 喜德县| 蓝田县| 阳原县| 辽阳市| 福清市| 新乡市| 扶沟县| 鄱阳县| 河间市| 乌兰察布市| 石泉县| 西林县| 恩平市| 蚌埠市| 湟源县| 宝兴县| 凤山市| 清徐县| 龙胜| 龙州县|