The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
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.

HttpRequestExtensions.cs 619B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Http;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Web;
  9. namespace Teknik.Helpers
  10. {
  11. public static class HttpRequestExtensions
  12. {
  13. public static string GetClientIpAddress(this HttpRequestMessage request)
  14. {
  15. if (request.Properties.ContainsKey("MS_HttpContext"))
  16. {
  17. return IPAddress.Parse(((HttpContextBase)request.Properties["MS_HttpContext"]).Request.UserHostAddress).ToString();
  18. }
  19. return null;
  20. }
  21. }
  22. }