Is it possible to submit simultaneously 2 forms to different actions? In the actions I want to set TempData and than redirect to third action.
I tried method described here Submit two forms with one button Let's suggest that each form have one input field. First form with "name" input, second with "lastname" input
submitForms = function(){
document.forms["formForFirstAction"].submit();
document.forms["formForSecondAction"].submit();
window.location("/Home/ThirdAction")
}
My Actions looks like...
[HttpPost]
public void FirstAction(string name) {
TempData["name"] = name;
}
[HttpPost]
public void SecondAction(string lastname) {
TempData["lastname"]=lastname;
}
public ActionResult ThirdAction () {
string fullname;
fullname = string.Format((string)TempData["name"] +
(string)TempData["lastname"]);
return View(fullname);
}
But it doesn't work. In most cases I got only name or last name in fullname string. Looks like it's something with async or other things I don't know much now. Can you please help me?