-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View components in Razor Pages #7018
Comments
Hello @ifo20 -- Thanks for asking. This topic is due for a 2.1 update that will convert it over to Razor Pages. The work is tracked on #5495. The engineers did provision Razor Pages apps to have a Shared folder on aspnet/Mvc#6604. You can add a Shared folder to your Pages folder. I think* that either of these paths will be ok ...
*think = I haven't tested personally. RE: The topic update, I'll attach this issue to the sample update tracking issue. I don't think we want to patch just that one spot for Razor Pages. The topic and sample are currently geared to MVC. The topic has a awful lot of "view" language that will require attention. |
@ifo20 if you create a Razor Pages project with the 2.1 templates, it has Pages/Shared |
Ah thanks guys - I was using 2.0 hence the template did not create the Shared folder. I am now using 2.1 and created a Components folder within the Shared folder as suggested. |
An app can have both. Razor Pages works with MVC as long as there are no route conflicts between controllers and pages. Sharing a layout among views and pages is a bit of an open question right now. A layout can be shared when full paths to it are used, but there's no "best practices" guidance from engineering yet on where to keep the layout page in the app. See the convo at #7336 (comment). |
I'm confused with this instruction: "Create the Views/Shared/Components folder. This folder must be named Components."
I am using Razor Pages rather than MVC. I don't have a Views folder or a Shared folder (infact the Razor intro says I shouldn't have a Views/Shared folder).
In my basic app I currently have, at the root level, a Pages folder, and a ViewComponents folder.
Should I create this 'Components' folder at the same level? Or within the Pages folder? Or can I put the same files in the ViewComponents folder?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: