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

164
Visualizações
ASP .Net Core Call Controller Function from Javascript with redirect from Controller

I am breaking my head on this and cant find a solution. In short I have a ASP .Net Core MVC page that has a Javascript list. I need to pass that list to a redirect. I have this in place and it is working so not the solution I am looking for as it is not secure.

So what I am trying to do is calling the Controller function from Javascript passing the list. I can only do this with Ajax but the controller wont redirect on an Ajax call. Is there anyone that has encountered a similar problem and possibly a solution for this?

Javascript var -> Controller -> redirect.

Thank you in advance guys

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I found the solution. So leaving the answer here for any future guys having the same problem.

Javascript

    $("#btn").click(function () {
       var PostData = ["1","2","3","4","5","6","7","8","9"]
       if (PostData != "") {            
          window.location.href ="Controller/Function?test=" + PostData
                   
       } else
         alert('Oops.!!');});

C# Controller

 public IActionResult Test(string test)
    {
        return RedirectToAction("function", "Controller", new { test });
    }
about 4 years ago · Juan Pablo Isaza Relatório
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