Get external IP address over remoting in C#

前端 未结 12 1676
夕颜
夕颜 2020-12-05 05:16

I need to find out the external IP of the computer a C# application is running on.

In the application I have a connection (via .NET remoting) to a

12条回答
  •  情深已故
    2020-12-05 05:56

    Patrik's solution works for me!

    I made one important change. In process message I set the CallContext using this code:

    // try to set the call context
    LogicalCallContext lcc = (LogicalCallContext)requestMessage.Properties["__CallContext"];
    if (lcc != null)
    {
        lcc.SetData("ClientIP", ipAddr);
    }
    

    This places the ip address in the correct CallContext, so it can later be retrieved with GetClientIP().

提交回复
热议问题