开发者

Hostheader not working in Azure

I have a multi-site web role set up in Azure. In my service definition file I have the following:

<Sites>
      <Site name="Web" physicalDirectory="..\ABC.WebUx">
        <Bindings>
          <Binding name="Abc" endpointName="Endpoint1" hostHeader="www.abc.com" />
        </Bindings>
      </Sit开发者_StackOverflowe>
      <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>

The hostheader works good when I try www.def.com and www.ghi.com however when entering www.abc.com it seems to ignore the physical directory and instead gives me a message like this:

    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.

Does anyone know why it seems to ignore the physical directory for the default "Web" which btw is the site that I have linked to my cloud service.

Your help would be much appreciated.

Nancy


If you're working with multiple websites I would recommend watching this Cloud Cover episode. During the episode they discuss that any site that has the name "Web" is treated as a special case by Azure and so properties like the physical directory are ignored. So to fix your specific problem change the name of your first site from "Web" to "ABC".


The default "web" site will always point to the project folder for the web role in your solution. You cannot overwrite it using the physicalDirectory attribute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜