WCF和多个主机标头 [英] WCF and Multiple Host Headers

查看:105
本文介绍了WCF和多个主机标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的雇主网站有多个主机名,所有主机名都在同一台服务器上,我们只是展示不同的皮肤用于品牌推广。

My employers website has multiple hostnames that all hit the same server and we just show different skins for branding purposes.

不幸的是,WCF似乎不能正常运行这个情况。

Unfortunately WCF doesn't seem to work well in this situation.

我试过使用自定义主机工厂覆盖默认主机

这是不是一个可接受的解决方案,因为它需要在所有主机上工作,而不仅仅是1。

That's not an acceptable solution because it needs to work from all hosts, not just 1.

我还看了这篇博客文章但要么我无法让它工作或者它不能解决我的问题。

I've also looked at this blog post but either I couldn't get it to work or it wasn't meant to solve my problem.

我得到的错误是这个集合已经包含一个带有方案的地址http

The error I'm getting is "This collection already contains an address with scheme http"

必须有一种方法来配置它,请帮助:)

There's got to be a way to configure this, please help :)

推荐答案

如果你没有在端点中放置一个地址,那么它应该解析为任何服务器命中服务。我使用此代码并将其解析为我的.local地址和IIS中的.com地址。

If you don't put an address in the endpoint then it should resolve to whatever server hits the service. I use this code and it resolves both to my .local address and to my .com address from IIS.

<system.serviceModel>
    <services>
        <service name="ServiceName" behaviorConfiguration="ServiceName.Service1Behavior">
            <endpoint address="" binding="wsHttpBinding" contract="iServiceName">
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="ServiceName.Service1Behavior">
                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata httpGetEnabled="true"/>
                <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

这篇关于WCF和多个主机标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆