How to detect binding from wcf service end

一世执手 提交于 2019-12-01 11:52:33

Why exactly do you care about this? Your service really shouldn't care, overall, which binding the client used to get to the service if that is going to affect the service behavior (in that case, it might really make more sense to have multiple separate services).

That said, I think one possible way would be to look at the endpoint address for the service, which I think you can get using something like this (untested):

var opCtxt = OperationContext.Current;
var epAddress = opCtxt.EndpointDispatcher.EndpointAddress;
var uri = epAddress.Uri;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!