controlling the name of a named pipe when hosting WCF net.pipe binding in IIS

后端 未结 2 1850
天涯浪人
天涯浪人 2020-12-16 05:40

I have a service accessible via http and net.pipe. It is being hosted in IIS 7 (Server 2008). I may be hosting different instances of this service for several customers on t

相关标签:
2条回答
  • 2020-12-16 06:22

    It appears that the host name portion of the URI is ignored and replaced by the implementation based upon the HostNameComparisonMode of the channel binding. You can try changing it to "Exact" via the service's configuration...

    http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.hostnamecomparisonmode.aspx

    NetNamedPipeBinding.HostnameComparisonMode The HostnameComparisonMode value that indicates whether the hostname is used to reach the service when matching the URI. The default value is StrongWildcard(), which ignores the hostname in the match.

    See the configuration syntax here: http://msdn.microsoft.com/en-us/library/ms731291.aspx

    0 讨论(0)
  • 2020-12-16 06:41

    This is an old question, but I figured I'd add my answer since I also needed an answer for this (and maybe there are others out there who need it too).

    The base address of an IIS-hosted WCF service is controlled by IIS and cannot be overridden in web.config. Instead, you can control the base addresses by updating the IIS site binding information for the site you're hosting your service in.

    Most of the documentation I found online suggests using * as the binding configuration for net.pipe. But if you instead use "virtualsite.com" as the binding configuration value, the base address of your net.pipe endpoint will be "virtualsite.com" rather than the machine name.

    Here is an example using appcmd to configure a site in IIS with the correct net.pipe binding:

    %windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.pipe',bindingInformation='virtualhostname.com']
    

    One note about HostnameComparisonMode, it has no effect in IIS according to MSDN:

    These values have no effect when used inside of the Internet Information Services (IIS) or Windows Process Activation Service (WAS) hosting environment. In those cases, WCF uses whatever hostname comparison mode is provided by the IIS Web Site hosting the WCF services.

    Instead, you have to use the mechanism I described above. I figured this out by investigating how hostname binding works in HTTP for IIS. Unfortunately, I've not been able to find any official documentation for this IIS-based scenario for other WCF transports.

    0 讨论(0)
提交回复
热议问题