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.