Created
May 10, 2012 14:36
-
-
Save MikeJansen/2653453 to your computer and use it in GitHub Desktop.
Revisions
-
Mike Jansen revised this gist
May 10, 2012 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // Original idea: http://stackoverflow.com/questions/9565889/get-the-ip-address-of-the-remote-host using System.Net.Http; using System.ServiceModel.Channels; using System.Web; @@ -24,4 +26,4 @@ public static string GetClientIpAddress(this HttpRequestMessage request) } } } } -
Mike Jansen revised this gist
May 10, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ using System.ServiceModel.Channels; using System.Web; namespace CrowSoftware.Api { public static class HttpRequestMessageHelper { -
Mike Jansen created this gist
May 10, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ using System.Net.Http; using System.ServiceModel.Channels; using System.Web; namespace InsureCommon.Api { public static class HttpRequestMessageHelper { public static string GetClientIpAddress(this HttpRequestMessage request) { if (request.Properties.ContainsKey("MS_HttpContext")) { return ((HttpContextWrapper)request.Properties["MS_HttpContext"]).Request.UserHostAddress; } else if (request.Properties.ContainsKey(RemoteEndpointMessageProperty.Name)) { RemoteEndpointMessageProperty prop; prop = (RemoteEndpointMessageProperty)request.Properties[RemoteEndpointMessageProperty.Name]; return prop.Address; } else { return null; } } } }