Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

460
Views
How to detect if a user is using a local ip, vpn or a public ip?

I am new to MVC. I am trying to create a landing page where the users may use it to open specific websites. I want to detect whether the user is accessing it through a local iPad or through a VPN or the public iPad. So I can direct them to the website using their specific address.

For example, I want to access our inventory system and on the landing page I would just click the button and direct them using their iPad.

For example I am using a local IP and that IP is 12.12.12.2 and the port number of our inventory system is 211. If I click on the button I want to be directed using that IP which will be 12.12.12.2:211 and same goes to VPN and public IP.

This is what I've tried

Controller:

  public ActionResult GetIP()
   {
      return Json(new { ip = Request.UserHostAddress }, JsonRequestBehavior.AllowGet);
   }

JS:

$("#target").click(function() {
   var port = $(this).attr("data-itemId");
    $.ajax({
        type: "POST",
        url: "/Home/GetIP/",
        success: function (data) {
            if (data.ip = '12.12.12.2'){ --local
                window.open('//' + '12.12.12.2:' + port);
            }
            if (data.ip = '12.12.12.7') { --vpn
                window.open('//' + '12.12.12.7:' + port);
            }
            if (data.ip = '123.123.123') { --public
                window.open('//' + '123.123.123.54:' + port);
            }
            else {
                alert(Error);
            }
        }
    });
});

I was able to direct it when I was using localhost. But when I tried to publish it on our server they open all at the same time. I get three tabs with the IP addresses.

I hope someone can help. Thank you so much.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!