forked from Teknikode/Teknik
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
619 B
24 lines
619 B
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Net; |
|
using System.Net.Http; |
|
using System.Text; |
|
using System.Threading.Tasks; |
|
using System.Web; |
|
|
|
namespace Teknik.Helpers |
|
{ |
|
public static class HttpRequestExtensions |
|
{ |
|
public static string GetClientIpAddress(this HttpRequestMessage request) |
|
{ |
|
if (request.Properties.ContainsKey("MS_HttpContext")) |
|
{ |
|
return IPAddress.Parse(((HttpContextBase)request.Properties["MS_HttpContext"]).Request.UserHostAddress).ToString(); |
|
} |
|
return null; |
|
} |
|
|
|
} |
|
}
|
|
|