0

I need to know the C# MVC equivalent of PHP's $_SERVER['REMOTE_ADDR'].

I am writing a C# backend program that accepting requsets from following limited remote addresses ip.

string[] ipArray = { "185.71.65.92", "185.71.65.189", "149.202.17.210" };

How to get client IP address in ASP.NET when using MVC 5.

I try do this but it doesn't work.

            string ipAddress= Request.ServerVariables["REMOTE_ADDR"]; 
            if (!Array.Exists(ipArray, element => element.Equals(ipAddress)))
                {
                TempData["err"] = "Bad request from wrong remote server!";
                }

When i using HttpContext apearing jpeg error. HttpContext block code image Can you please let me know how to slove it?

aram
  • 5
  • 6

0 Answers0