Hi setwell,
Refer below example.
Model
public class BasicInfo
{
public string? Name { get; set; }
public int Age { get; set; }
}
Controller
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(BasicInfo basic)
{
return View("Fetch", basic);
}
[HttpGet]
public ActionResult Fetch(BasicInfo basic)
{
return View(basic);
}
}
View
Index
@addTagHelper*, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<form method="post" asp-controller="Home" asp-action="Index">
<h4>Basic Info</h4>
<table>
<tr>
<td>Name</td>
<td><input type="text" name="Name" /></td>
</tr>
<tr>
<td>Age</td>
<td><input type="text" name="Age" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Create" /></td>
</tr>
</table>
</form>
</body>
</html>
Fetch
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Fetch</title>
</head>
<body>
<table>
<tr>
<td>Name</td>
<td>@Model.Name</td>
</tr>
<tr>
<td>Age</td>
<td>@Model.Age</td>
</tr>
</table>
</body>
</html>
Screenshot
