Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

464
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda