Razor Pages basics
A form with no JavaScript. Submit it empty, then with a name, and watch the address bar.
OnGetruns when the page loads.- Submitting POSTs the form to the same URL;
OnPostruns.[BindProperty]has already copied the form fields intoInput, and the attributes onGreetingInputhave filledModelStatewith any errors. - Invalid:
return Page()re-shows the form with the errors next to the field. - Valid: the message goes into
TempDataandRedirectToPage()sends the browser back with a fresh GET. That's Post/Redirect/Get: refreshing the page won't resubmit the form.