Learn
Well done! We’ve covered a lot of page model concepts. Let’s review:
- When a
GET
request is made to a page, theOnGet()
orOnGetAsync()
method from its page model is invoked. - When a
POST
request is made to a page, theOnPost()
orOnPostAsync()
method from its page model is invoked. - URL query string values can be accessed via a method’s parameters.
- URL query string values can also be accessed via model binding, which is activated using
[BindProperty]
. - The
asp-for
attribute in Input Tag Helpers connects an<input>
element to a model property. - The
asp-route-{value}
attribute in Anchor Tag Helpers adds additional information to a link. - Synchronous handler methods, like
OnGet()
andOnPost()
, with no return statement will have a return type ofvoid
. - Asynchronous handler methods, like
OnGetAsync()
andOnPostAsync()
, with no return statement will have a return type ofTask
.
If you’d like to see other examples of handler methods, look at the first few sections of this introduction to Razor Pages by Microsoft and check out the Handler Methods section on Learn Razor Pages.
Instructions
Before you move on, make sure you can answer the following questions. You can poke around the app code for hints:
- When are
OnGet()
andOnPost()
called? - Within an Input Tag Helper what does the
asp-for
attribute do? - How is
[BindProperty]
used?
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.