I am attempting to obtain similar information as found on https://www.whatismybrowser.com. I specifically am looking for the external and local IP addresses. This is the .NET Core code that I am using to obtain this information:
HomeController.cs
ViewData["RemoteIp"] = HttpContext.Connection.RemoteIpAddress.ToString();
ViewData["LocalIp"] = HttpContext.Connection.LocalIpAddress.ToString();
Startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor
});
The application lives behind an F5, so it results with a remote IP with my machine IP and a local IP that is the loopback IP address. The DNS entry is available externally, which then goes through the F5, then points to the server running the application.
Ideally, I would like the remote IP to return the external IP as done in the ipify API.
I've reviewed the following SO threads already in attempt for a solution: How to get Client IP address in ASP.NET Core 2.1
I've also reviewed the MSDN documentation as found here: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-2.1
One other factor: I plan on reusing this concept across multiple devices, including iOS, Android, and Windows platforms. I haven't decided on a framework, but I've entertained the ideas of Xamarin and PhoneGap.