WCF (.net4.0) 中舍去.svc文件

WCF (.net4.0) 中舍去.svc文件

非常简单,只需要配置web.config文件即可。省掉.svc文件简化了文件管理的开销。

web.config

 

 1 <system.serviceModel>
 2 
 3     <serviceHostingEnvironment>
 4       <serviceActivations>
 5         <add service="WcfService2.Services" relativeAddress="~/test.svc"/>
 6       </serviceActivations>
 7     </serviceHostingEnvironment>
 8 <!-- 
 9 ....
10 ....
11 ....
12 -->
13 </system.serviceModel>

service: 命名空间.类

relativeAddress: 设置一个.svc文件名称

 

 

 

 

 

原文地址:https://www.cnblogs.com/server126/p/2638037.html