- Do Razor Pages use code-behind?
Yes, they can, but it is not mandatory. The code-behind class must inherit from PageModel and be located together with the .cshtml file.
- What is the purpose of the Page Model?
It is where the handlers for the different HTTP verbs (GET, POST, and so on) are implemented.
- What are page handlers?
They are the code that processes the requests inside a PageModel class.
- How can we restrict a Razor Page from being called by anonymous users?
We add a convention using the AllowAnonymousToPage extension method when configuring Razor Page options with the AddRazorPagesOptions method, following AddMvc.
- What are the two ways by which we can inject services into a Razor Page? ...