2018-06-15 02:57:03 +02:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using System;
|
2016-02-26 01:41:31 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
2017-01-18 09:12:22 +01:00
|
|
|
|
namespace Teknik.Utilities
|
2016-02-26 01:41:31 +01:00
|
|
|
|
{
|
|
|
|
|
public static class HttpRequestExtensions
|
|
|
|
|
{
|
|
|
|
|
public static string GetClientIpAddress(this HttpRequestMessage request)
|
|
|
|
|
{
|
|
|
|
|
if (request.Properties.ContainsKey("MS_HttpContext"))
|
|
|
|
|
{
|
2018-06-15 02:57:03 +02:00
|
|
|
|
return IPAddress.Parse(((HttpContext)request.Properties["MS_HttpContext"]).Request.Host.Value).ToString();
|
2016-02-26 01:41:31 +01:00
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|