我可以在WCF中的IIS下的一个虚拟目录中有多个.svc文件吗?

chu*_*h97 7 wcf

我可以在WCF中的IIS下的一个虚拟目录中有多个.svc文件吗?如果是这样的话?

Dar*_*rov 8

您需要有两个服务合同,并且在该web.config部分中您需要注册两个服务:

<system.serviceModel>
    <services>
        <service name="YourNamespace.Service1" 
                 behaviorConfiguration="returnFaults">
            <endpoint 
                address="" 
                binding="basicHttpBinding"           
                contract="Yournamespace.IService1" />
        </service>
        <service name="YourNamespace.Service2" 
                 behaviorConfiguration="returnFaults">
            <endpoint 
                address="" 
                binding="basicHttpBinding"           
                contract="Yournamespace.IService2" />
        </service>
    </services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

然后,您可以.svc为每个服务提供两个文件.