Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pankajkumar PatelRank #181 · 13.4K reputationPosted Nov 21, 2022, 12:53 AM EST
Hi Naresh Beniwal,
For automatic model binding in razor pages in asp.net core you have to follow some steps one by one. This is described easily with actual example in following link:
Hope, this will help you!
Vishal YelveRank #178 · 13.6K reputationPosted Nov 21, 2022, 5:07 AM EST
https://endjin.com/blog/2022/01/model-binding-in-asp-net-core-using-razor-pages
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Nov 22, 2022, 1:24 AM EST
One way public class ModelBindingModel : PageModel { [BindProperty] public string Name { get; set; } [BindProperty] public string Email { get; set; } public void OnGet() { } public void OnPost() { ViewData["confirmation"] = $"{Name}, information will be sent to {Email}"; } } other way [BindProperties] public class ModelBindingModel : PageModel { public string Name { get; set; } public string Email { get; set; } public void OnGet() { } public void OnPost() { ViewData["confirmation"] = $"{Name}, information will be sent to {Email}"; } } Binding complex object public class Login { public string Email { get; set; } public string Password { get; set; } } public class ModelBindingModel : PageModel { [BindProperty] public Login Login { get; set; } public void OnGet() { } public void OnPost() { ViewData["welcome"] = $"Welcome {Login.Email}"; } }