@manhnguyenv

Welcome to my blog!

Get the IP Address in .NET

June 18, 2018 20:56
public class HomeController : Controller
{
    // GET: Home
    public ActionResult Index()
    {
        string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (string.IsNullOrEmpty(ipAddress))
        {
            ipAddress = Request.ServerVariables["REMOTE_ADDR"];
        }
        ViewBag.IPAddress = ipAddress;
 
        return View();
    }
}

Get IP Address In ASP.NET

https://www.c-sharpcorner.com/article/get-ip-address-in-Asp-Net/

Categories

Recent posts