I mean, you can do whatever you like, basically? Here’s an example that just displays the title of the current Hosting Environment by injecting IWebHostEnvironment
right into the Razor page:
@page
@model MyApp.IndexModel
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment Env
<h1>@Env.EnvironmentName</h1>
That’s pretty much how it’s done in this sample from the docs: https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/environments/samples/6.x/EnvironmentsSample/Pages/About.cshtml