1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | OperationContext context = OperationContext.Current; MessageProperties properties = context.IncomingMessageProperties; RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; string address = string.Empty; //http://www.simosh.com/article/ddbggghj-get-client-ip-address-using-wcf-4-5-remoteendpointmessageproperty-in-load-balanc.html if (properties.Keys.Contains(HttpRequestMessageProperty.Name)) { HttpRequestMessageProperty endpointLoadBalancer = properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty; if (endpointLoadBalancer != null && endpointLoadBalancer.Headers["X-Forwarded-For"] != null) address = endpointLoadBalancer.Headers["X-Forwarded-For"]; } if (string.IsNullOrEmpty(address)) { address = endpoint.Address; } ----------------------------------------------- private string GetIP() { OperationContext context = OperationContext.Current; MessageProperties prop = context.IncomingMessageProperties; RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; string ip = endpoint.Address; return ip ; } | cs |
'C#' 카테고리의 다른 글
[c#] app config connectionStrings 윈도우 인증 (0) | 2021.06.14 |
---|---|
app.config에서 연결 문자열 암호화 (0) | 2020.07.21 |
[C#] popup browser share session (새창 세션 공유) (0) | 2017.07.25 |
[c#] Start a new process and Killing the current process (A프로그렘에서 B띄우기) (0) | 2017.07.18 |
[C#] C# WebBrowser version 변경 (0) | 2017.07.04 |