解决:路径“/WebSite/App_GlobalResources/”映射到此应用程序外部的目录,这是不受支持的

        这几天在建ASP.NER网站时,新建的每个网站都出现同样的错误:
       路径“/WebSite/App_GlobalResources/”映射到此应用程序外部的目录,这是不受支持的。

      这困扰了我好几天后,终于找到了解决方法,现分享给大家:
在IIS中右击WebSite,点“属性”,在“目录”的“应用程序设置”中,点“删除”删除“应用程序名”就可以了。如果在这样以后,还出现:

“在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。如果在 IIS 中没有将虚拟目录配置为应用程序,则可能导致此错误。”

     这样的错误,在Web.config文件中删除<authentication mode="Windows" />结点就可以了。

      另外在网站的子文件夹中的Web.config文件中不能有<authentication />




This error can be caused by a virtual directory not being configured as an application in IIS.

这个报错一般是由于两种报错引起的。

1是由于您没有为目录创建一个Application

如果你用的是空间商提供的虚拟空间,出现这样的问题很可能是你的空间配置问题,一般虚拟空间都会提供给你一个增加虚拟文件夹的功能。


2是由于您在站点的子目录中的web.config中加入了只能在根目录中配置的信息。如Session或是权限。

具体的解决方法如下:



You may get this error when trying to browse an asp.net application.

The debug information shows that "This error can be caused by a virtual directory not being configured as an application in IIS."

However, this error occurs primarily out of 2 scenarios.

1. When you create an new web application using visual studio.net, it automatically creates the virtual directory and configures it as an application. However, if you manually create the virtual directory and it is not configured as an application, then you will not be able to browse the application and may get the above error. The debug information you get as mentioned above, is applicable to this scenario.

To resolve it, Right Click on the virtual directory - select properties and then click on
"Create" next to the "Application" Label and the textbox. It will automatically create the "application" using the virtual directory's name. Now the application can be accessed.


2. When you have sub-directories in your application, you can have web.config file for the sub-directory. However, there are certain properties which cannot be set in the web.config of the sub-directory such as authentication, session state (you may see that the error message shows the line number where the authentication or sessionstate is declared in the web.config of the sub-directory). The reason is, these settings cannot be overridden at the sub-directory level unless the sub-directory is also configured as an application (as mentioned in the above point).

Mostly we have the practice of adding web.config in the sub-directory if we want to protect access to the sub-directory files (say, the directory is admin and we wish to protect the admin pages from unathorized users).

But actually, this can be achieved in the web.config at the application's root level itself, by specifing the location path tags and authorization, as follows:-

<location path="Admin">


    <system.web>


      <authorization>


	<allow roles="administrators" />


	<deny users="*" />


      </authorization>


    </system.web>


</location>




However, if you wish to have a web.config at the sub-directory level and protect the sub-directory, you can just specify the Authorization mode as follows:-

<configuration>


<system.web>


<authorization>


     <allow roles="administrators" />


     <deny users="*" />


 </authorization>


</system.web>


</configuration>




Thus you can protect the sub-directory from unauthorized access.


http://forums.asp.net/t/769696.aspx


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值