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

115
Views
unable to redirect to the line from where the action method is called in mvc

I have the following script code.

<script>
    function Save(id, cabinsId) {
        var Fid = id;
        var cid = cabinsId;
        window.location.href = '@Url.Action("signUp","User")';
        $.ajax({
            method: 'GET',
            url:'/Flights/ReserveFlight',
            data: { FlightId: Fid, CabinId: cid }
        });
    }
        </script>

Here in this script, I called the first action method signUp in the User controller on this line

window.location.href = '@Url.Action("signUp","User")';

from this line the called function gets executed successfully. here is the function

public ActionResult signUp()
        {
            List<Gender> genders = db.Gender.ToList();
            ViewBag.gender = new SelectList(genders, "Genderid", "P_Gender");

            List<City> cityList = db.Cities.ToList();
            ViewBag.cityList = new SelectList(cityList, "CityId", "CityName");
            return View("_SignUp");
        }


        [HttpPost]
        public ActionResult signUp(Pessenger pessenger)
        {
            if(ModelState.IsValid == true)
            {
                db.Pessengers.Add(pessenger);
                db.SaveChanges();
                Session["UserId"] = pessenger.PessengerId;
            }
            return View();
        }

In the user controller, the user gets signed up. but at the end of httpPost version signUp method, I am unable to return to the script code from where I called the signUp method.

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!