You must Sign In to post a response.
  • Category: .NET

    Getting Ip Address In MVC


    How can i get the IP address in mvc.

    i have one menu when i clcik it, it will show the IP address. please it is urgent any one explain me with controller and view
  • #769039
    Hai Prasanta Kumar,
    Getting the IP address code is same for all the languages or frameworks. You just need to use the same code in Controller class and get the IP address as below:

    using System.Net;

    var ipAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList.GetValue(0).ToString();

    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #769079
    You can use given code snippet within a Controller to Getting Ip Address In MVC
    using System;
    using System.Web.Mvc;

    namespace Mvc.Controllers
    public class HomeController : ClientController
    public ActionResult Index()
    string ip = Request.UserHostAddress;

  • Sign In to post your comments