This works fine for webhosted scenarios. If you want to get the client address
in self-hosted scenarios, you need to look for the
RemoteEndpointMessageProperty in the property bag.
if (this.Request.Properties.ContainsKey(RemoteEndpointMessageProperty.Name)) {
RemoteEndpointMessageProperty prop;
prop = (RemoteEndpointMessageProperty)this.Request.Properties[RemoteEndpointMessageProperty.Name];
Console.WriteLine(prop.Address);
}
CarlosFiguei...
Member
99 Points
19 Posts
Microsoft
Re: How to get the client IP address for the current controller call.
Feb 28, 2012 12:03 AM|LINK
This works fine for webhosted scenarios. If you want to get the client address in self-hosted scenarios, you need to look for the RemoteEndpointMessageProperty in the property bag.
if (this.Request.Properties.ContainsKey(RemoteEndpointMessageProperty.Name)) { RemoteEndpointMessageProperty prop; prop = (RemoteEndpointMessageProperty)this.Request.Properties[RemoteEndpointMessageProperty.Name]; Console.WriteLine(prop.Address); }