如何获得的WCF Web服务的IP地址 [英] How to get IP address of WCF web service

查看:114
本文介绍了如何获得的WCF Web服务的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当调用从C#客户端一个WCF Web服务(例如System.ServiceModel.ClientBase<的;?>)我怎样才能得到服务器的IP地址,我连接到

When calling a WCF web service from a C# client (instance of System.ServiceModel.ClientBase<>) how can I get the IP address of the server I'm connected to?

上下文:我们已经设置了一些WCF服务的Web场,我需要知道我哪些特定的服务器连接发生异常时,以

Context: we've setup a web farm for some WCF services and I need to know which specific server I'm connected to when an exception occurs.

推荐答案

您可以添加到您的陷阱:

You can add this to your catch:

    IPHostEntry heserver = Dns.GetHostEntry(Dns.GetHostName());
    IPAddress curAdd = heserver.AddressList[0];
    curAdd.ToString();

这篇关于如何获得的WCF Web服务的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆