WCF service configuration file question regarding <baseAddresses>

♀尐吖头ヾ 提交于 2019-11-26 09:45:43

问题


From what I\'ve seen the tag is ignored when hosting a WCF service in IIS. I understand that when self-hosting this is required but is this harmful or even used when operating under IIS?

ex.

<system.serviceModel>
  <service blah blah blah>
    <host>
      <baseAddresses>
        <add baseAddress=\"http://localhost/blah\" />
      </baseAddresses>
    </host>
   </service>
</system.serviceModel>

From what I\'ve seen you can take a config file describing a service from one machine and use that on a completely different machine and it works fine. It looks as if IIS completely ignores this section.

Thanks, kyle


回答1:


As you have guessed, the baseAddresses element is completely ignored when hosting in IIS. The service's base address is determined by the web site & virtual directory into which your wcf service is placed.

Even when self-hosting, baseAddresses is not required. It is merely a convenience that avoids you having to enter a full address for each endpoint. If it is present, the endpoints can have relative addresses (relative to the base address, that is).




回答2:


base address required for selfhosting. IIS/WAS hosts ignores the base address.




回答3:


According to the MSDN Microsoft documentation in the below link, midway through the page in the Note section states, "Services hosted under Internet Information Services (IIS) or Windows Process Activation Service (WAS) use the virtual directory as their base address."

http://msdn.microsoft.com/en-us/library/ee358768(v=vs.110).aspx



来源:https://stackoverflow.com/questions/56249/wcf-service-configuration-file-question-regarding-baseaddresses

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!