从我的子应用程序中的父应用程序的web.config获取错误 [英] Getting errors from web.config of parent application in my sub application
问题描述
我的主网站应用程序在我的服务器上 C:\inetpub \ _www
,我可以在 http://查看www.mysite.com
I have my main website's application on my server at C:\inetpub\wwwroot
, which I can view at http://www.mysite.com
我创建了另一个单独的MVC Web应用程序,名为 Supapp
,在 C:\inetpub \Supapp
。我想设置它,这样如果我访问 http://www.mysite.com/Subdir
,它将运行我的 Subdir
app。
I've created another separate MVC web application, named Supapp
, at C:\inetpub\Supapp
. I'd like to set it up so that if I visit http://www.mysite.com/Subdir
, it will run my Subdir
app.
所以我进入IIS,扩展了我现有的网站,并添加了一个新的应用程序,将根文件夹指向 C:\inetpub \Supapp \
。
So I went into IIS, expanded my existing website, and added a new Application, pointing the root folder to C:\inetpub\Supapp\
.
当我去查看 http:// www .mysite.com / Subdir
,我收到编译错误:
When I go to view http://www.mysite.com/Subdir
, I get a compilation error:
编译器错误消息:CS0246 :找不到类型或命名空间名称'MySite'(您是否缺少using指令或程序集引用?)
Compiler Error Message: CS0246: The type or namespace name 'MySite' could not be found (are you missing a using directive or an assembly reference?)
源错误:
Line 98: <add namespace="System.Web.Mvc.Html" />
Line 99: <add namespace="System.Web.Routing" />
Line 100: <add namespace="MySite.HtmlHelpers" />
Line 101: </namespaces>
Line 102: </pages>
源文件: c:\ inetpub \wwwroot \web.config 行 100
Source File: c:\inetpub\wwwroot\web.config Line: 100
因此出于某种原因,我的子应用程序尝试从父应用程序加载命名空间时收到错误。
So for some reason, my sub application is getting an error from trying to load a namespace from the parent application.
有没有办法解决这个问题? Subdir
应用程序位于完全不同的目录中。
Is there a way around this? The Subdir
application is in a completely different directory.
推荐答案
配置文件是分层的,你的子web.config从你的root .config继承东西。如果您想要忽略某些部分,可以将 inheritInChildApplications =false
属性添加到不被继承的标记中。
config files are hierarchical, your sub web.config inherit things from your root .config. If you want certain parts to be ignred you can add inheritInChildApplications="false"
attribute to tags you don't to be inherited.
根据您的情况,将 inheritInChildApplications =false
添加到您的aplication root location
For your case add inheritInChildApplications="false"
to your aplication root location
<location path="." inheritInChildApplications="false">
</location>
这篇关于从我的子应用程序中的父应用程序的web.config获取错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!