我有一个带有 IIS6 的 WinSrv2k3 盒子,托管一系列站点,其中一个是 VB/.NET2 站点。在其中我创建了一个虚拟目录并将其指向一个非常简单的 C#/.NET3.5 站点目录。我原本希望该网站允许我像普通网站一样查看页面(虚拟目录中只有一个 ASMX),但是当从浏览器访问该页面时,我得到:

Server Error in '/TestVbSite' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Could not load file or assembly 'IMSControls' or one of its dependencies. The system cannot find the file specified. (D:\sites\TestVbSite\web.config line 211)

Source Error: 


Line 209:    </httpHandlers>
Line 210:    <httpModules>
Line 211:      <add name="UrlRewritingModule" type="IMS.Controls.HttpModules.UrlRewritingModule, IMSControls" />
Line 212:    </httpModules>
Line 213:  </system.web>

Source File: D:\sites\TestVbSite\web.config    Line: 211

我在那里看到的问题是,引发异常的 web.config 似乎是父网站的 .config,而不是虚拟目录中的 web.config。但我不明白为什么。

当访问网站内的常规页面(不在虚拟目录下)时,它们会正常渲染和执行,这表明 IMSControls DLL 无法从虚拟目录加载,但同样,我不明白为什么这会涉及到的过程。

有帮助吗?

解决方案

好吧,好吧,在经历了一些错误的开始之后,大量的谷歌搜索给了我要寻找的正确的东西:web.config 继承。

基本上,要阻止虚拟目录继承其父站点的 web.config 的属性(以及因此产生的任何问题),父站点的 web.config 需要具有其 <system.web> 元素包裹在一个新的(对我来说)标签中:

<location path="." inheritInChildApplications="false">
  <system.web>
    ...
  </system.web>
</location>

有用的链接:

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

http://dotnetslackers.com/Security/re-55457_Stopping_ASP_NET_web_config_inheritance.aspx

http://msdn.microsoft.com/en-us/library/ms178685.aspx

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top