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

160
Views
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 answers
Answer question

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 Report
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!