我在Azure中设置了多站点Web角色。在我的服务定义文件中,我有以下内容:
<Sites>
<Site name="Web" physicalDirectory="..\ABC.WebUx">
<Bindings>
<Binding name="Abc" endpointName="Endpoint1" hostHeader="www.abc.com" />
</Bindings>
</Site>
<Site name="DEF" physicalDirectory="..\DEF.WebUx">
<Bindings>
<Binding name="Def" endpointName="Endpoint1" hostHeader="www.def.com" />
</Bindings>
</Site>
<Site name="Ghi" physicalDirectory="..\GHI.WebUx">
<Bindings>
<Binding name="Ghi" endpointName="Endpoint1" hostHeader="www.ghi.com" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
当我尝试www.def.com和www.ghi.com时,主机工作正常,但是当进入www.abc.com时,似乎忽略了物理目录,而是给我一个这样的信息:
Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.
The request for 'Home' has found the following matching controllers:
ABC.WebUx.Controllers.HomeController
DEF.WebUx.Controllers.HomeController
GHI.WebUx.Controllers.HomeController
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.InvalidOperationException: Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.
有谁知道为什么它似乎忽略了默认“Web”的物理目录,而btw就是我链接到我的云服务的网站。
非常感谢您的帮助。
南西
答案 0 :(得分:1)
如果您正在使用多个网站,我建议您观看此Cloud Cover episode。在这一集中,他们讨论任何名为“Web”的站点都被Azure视为特殊情况,因此忽略了物理目录等属性。因此,要解决您的具体问题,请将您的第一个站点的名称从“Web”更改为“ABC”。
答案 1 :(得分:0)
默认的“web”站点将始终指向解决方案中Web角色的项目文件夹。您无法使用physicalDirectory
属性覆盖它。