4,826 questions
Your approach is perfectly fine.
The other option is to set a default layout in the viewstart and then override the Layout in those pages where you want to use the other layout
@{
Layout = "_Layout";
}
Refer: https://www.learnrazorpages.com/razor-pages/files/layout