[英]WCF Service on IIS. How to get rid of the “Service.svc” component in the URL path?
[英]When Will the Default Constructor of Service.svc in a WCF Service is executed?
这是示例代码
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class Service : IService
{
public Service()
{
// here I am getting value from web.config
// using configurationManager which will be
// changing frequently
}
//Method1
....
//Method2
.....
}
我的服务的构造函数什么时候执行? 在第一个请求中还是在每个请求中?
对于服务的每个请求/调用,都会调用构造函数。
另外, 更改 web.config时,如果您的应用程序托管在IIS中,则应用程序池将回收。
如果您通过下面的浏览器使用/调用WCF服务,则每次调用都会创建服务的新对象,因此请执行服务的默认构造函数。
浏览器调用:... / priceatadataservice / DataService.svc / web / GetHistoryData
但是,如果您通过添加对其他项目的引用来调用服务,则仅当您创建服务对象时,它才是调用/执行构造函数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.