开发者

WCF - if service initialisation fails custom validation, deactivate service

how would you best go about the task of deactivating further use of a IIS6 or 7 hosted WCF service based on framework 3.5,开发者_如何学运维 when a custom condition is detected.

I thought perhaps that you could create a static constructor in the service implementation (i.e. .svc code behind file) that validates my app settings, should one of the settings be invalid, I could throw an exception. Thinking that the WCF infrastructure would fail to start and so IIS would provide a 401 error (or alike) when browsing the svc file.

I feel this is to easy, im thinking perhaps this is not the right thing to do, perhaps i need to be implementing another WCF interface to plug into some sort of WCF activation logic and signal a no-start. Or something like that?

Any ideas.

Many thanks Chris


I have found that the best place to do this is by creating a custom service factory implementation. Perform the validation before service creation, if it fails then throw an exception there, not in the constructor of the service implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜