本文介绍了如何在WCF中获取客户端地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我正在开发一个到WCF迁移项目的Web服务。在我的旧Web服务中,我有以下代码来获取客户端IP地址Hi All,I am working on a web service to WCF migration project. In my old web service, I have following piece of code for gettign the client IP addressContext.Request.ServerVariables["REMOTE_ADDR"]) 我在Windows服务中托管我的新WCF服务,并使用nettcpBinding(net.tcp)来获得更好的性能。 我担心的是我想用新代码替换aboce代码以获取WCF中的客户端IP地址。 I已经尝试过了。I am hosting my new WCF service in a Windows service and using nettcpBinding(net.tcp) for better performance.My concern is I want to replace the aboce piece of code with new code for getting the Client IP address in WCF.Things I have tried already.public string GetClientIPAddress() { return ((RemoteEndpointMessageProperty)OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name]).Address; } 但它以格式:: 1(IPv6) 无论如何以IPv4格式获取客户端IP地址(11.12.13.140)? 提前致谢。 快乐编码推荐答案 这篇关于如何在WCF中获取客户端地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 07:10
查看更多