私の最初のコントローラ:のasp.net mvc5にルーティングするように値を渡す
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(personalInfoModel personalInfo)
{
if (ModelState.IsValid)
{
TempData["key"] = personalInfo.CNIC;
PersonalInfoViewModel pivm = new PersonalInfoViewModel();
pivm.AddNewRecord(personalInfo);
return RedirectToAction("Create", "Experience", new { key = personalInfo.CNIC});
}
return View();
}
そして、私の第二のコントローラのコードは次のとおりです。
public ActionResult Create(string key)
{
if (filled == true)
{
TempData["alertMessage"] = "<script>alert('Fill it first!')</script>";
}
filled = true;
return View(key);
}
[HttpPost]
public ActionResult Create(experiencesModel experiences, string key)
{
filled = false;
ExperiencesViewModel evm = new ExperiencesViewModel();
evm.AddNewRecord(experiences, key);
return View();
}
私はここで第二のコントローラに第一のコントローラからのキーを渡したいです私はエラーに直面しています:
The view '42201-09007860-1' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Experience/42201-09007860-1.aspx ~/Views/Experience/42201-09007860-1.ascx ~/Views/Shared/42201-09007860-1.aspx ~/Views/Shared/42201-09007860-1.ascx ~/Views/Experience/42201-09007860-1.cshtml ~/Views/Experience/42201-09007860-1.vbhtml ~/Views/Shared/42201-09007860-1.cshtml ~/Views/Shared/42201-09007860-1.vbhtml
どうすればこの問題を解決できますか?コントローラからコントローラへの値渡しについての明確化が必要です。
RouteValueDictionaryの代わりにオブジェクトを受け取りRedirectToActionに2番目のオーバーロードがあります。あなたの新しい{}がオブジェクトとして誤って認識されているのでしょうか?実際のRouteValueDictionaryを作成してみてください。 https://msdn.microsoft.com/de-de/library/dd460311(v=vs.118).aspx – SlapY