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

首頁 > 編程 > .NET > 正文

虛擬主機上asp.net運行權限不足問題及解決

2024-07-10 13:10:08
字體:
來源:轉載
供稿:網友


   有些時候我們寫的asp.net應用程序是運行在虛擬主機上。有一些虛擬主機可能是由于安全的考慮,對asp.net做了權限設置,會導致我們的應用程序無法正常運行。

問題現象:
     由于某種原因,asp.net不能加載某些dll文件,出現如下錯誤提示: 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

  問題分析:

    根據我的觀察,asp.net應用程序直接生成的dll可以正常加載,由asp.net直接調用的外部dll也可以正常加載,但是僅被外部dll引用的其他外部dll不能加載。我的猜想是:由于權限是不完全的,asp.net應用本身生成的dll和直接引用的dll可以通過權限的繼承獲得權限,而僅被外部dll引用的其他外部dll因為權限的限制不能繼承權限,因此出現了權限不足的問題。

  問題解決:

    通過在我電腦的試驗,推測虛擬主機上修改了根web.config(在我電腦上其位置為c:/windows/microsoft.net/framework/v2.0.50727/config)的設置.
    默認web.config的權限設置節如下:

<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>

    推測虛擬主機上修改之后的設置:

 <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> 

   他首先設置了allowoverride為false,這就阻止了在用戶web.config中重新定義權限的能力。然后,他定義trust level為high,而不是默認的full。經我測試,只要trust level不為full,僅被外部dll引用的其他外部dll就不能被加載。 因此,我建議技術支持將allowoverride節設置為true。這樣我就可以在web.config中重新指定權限了。

例:<trust level="full" originurl="" />

    最近已經不研究aps.net了,因此也沒有認真去查找深層的原因,或許我的認識還有誤。希望那位高手可以道出深層的原因,或指正我的錯誤。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宿州市| 临武县| 肇州县| 湖州市| 九龙坡区| 乐东| 黑山县| 永定县| 武胜县| 宣化县| 交口县| 永嘉县| 化德县| 托克逊县| 五台县| 简阳市| 民权县| 淮南市| 富川| 新宁县| 邢台市| 龙山县| 天门市| 刚察县| 武夷山市| 溧水县| 安溪县| 保康县| 枝江市| 贡嘎县| 德庆县| 滨州市| 邵阳县| 广宗县| 衡南县| 教育| 高淳县| 黑龙江省| 聊城市| 怀远县| 迁西县|