In .NET Framework MVC, I could do it with the following codes:
public class HomeController : Controller
{
public ActionResult Index()
{
Student student = new Student()
{
Id = 2, Name = "Mike"
};
return View("About", student);
}
}
How do I convert the code above to Razor Pages (not MVC). At the moment for Razor Pages, I can only return the object to the same Page by making use the of the [BindProperty] attribute and the return is just basically return Page() and for redirect, I would just use return RedirectToPage("/Home/About");.
RedirectToPageis the correct method. You can use TempData (learnrazorpages.com/razor-pages/tempdata) to pass the student to the About page when you redirect.