Ronald Abellano

Ronald Abellano

  • NA
  • 161
  • 35.7k

Pass model through RedirectToAction

Jun 30 2018 11:55 AM
 Hi, how can we pass model to another page?
I'am using ASP.Net Core2.0
The data is passed in address bar but its not showing up in the model.  
 
Controller
[HttpPost]
public IActionResult Error()
{
return RedirectToAction(nameof(ExceptionPageController.Index), "ExceptionPage", new ExceptionPageModel { ErrorMessage ="Hello World!"});
}
 
View
@model Webeu.Models.ExceptionPage.ExceptionPageModel
@{
ViewData["Title"] = "Index";
}

<form asp-controller="Account" asp-action="Error" method="get">
<p>form</p>
<p> @Html.DisplayNameFor(m => m.ErrorMessage)</p>
<p>arigato @Html.DisplayFor(m => m.ErrorMessage)</p>
</form>

Answers (1)