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

116
Visualizações
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
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