1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00
Teknik/Utilities/HttpRequestExtensions.cs

23 lines
595 B
C#

using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
namespace Teknik.Utilities
{
public static class HttpRequestExtensions
{
public static string GetClientIpAddress(this HttpRequestMessage request)
{
if (request.Properties.ContainsKey("MS_HttpContext"))
{
return IPAddress.Parse(((HttpContext)request.Properties["MS_HttpContext"]).Request.Host.Value).ToString();
}
return null;
}
}
}