Tag Archives: asp.netcore
Get IP Address in Asp.net Core API
To get the client’s IP address in an ASP.NET Core API controller, Private IP Address var privateIPAddress = HttpContext.Connection.RemoteIpAddress?.ToString(); Public IP Address string url = “https//atulbaba.com”;var request = System.Net.WebRequest.Create(url);var getResponse = request.GetResponse();var reader = new System.IO.StreamReader(getResponse.GetResponseStream());var response = reader.ReadToEnd().Trim(); var responseArray = response.Split(new Char[] { ‘:’, ‘<‘ },StringSplitOptions.RemoveEmptyEntries); var publicIPAddresss = responseArray[6]; using Microsoft.AspNetCore.Mvc; using…