Learn

Use the file manager to open Index.cshtml.cs to see how the PageModel class is built for the page. Notice that the class name matches the Razor page name with the suffix Model. These classes must inherit from the PageModel class. By default, a logger service is injected into the constructor for the PageModel. This enables centralized error logging.

We will use the same injection approach to access our data services.

Instructions

1.

The file Index.cshtml.cs is open. This defines the PageModel for the page. Notice that the class name matches the Razor page name with the suffix Model.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?