Last post Sep 03, 2019 10:15 AM by ngaisteve1
Sep 03, 2019 06:52 AM|ngaisteve1|LINK
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");.
Sep 03, 2019 08:06 AM|Mikesdotnetting|LINK
You can use TempData to pass the student object to the About page: https://www.learnrazorpages.com/razor-pages/tempdata
Sep 03, 2019 10:15 AM|ngaisteve1|LINK
I found out how already
return new RedirectToPageResult("About", student);