-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Should Pages search in /Pages/Shared ? #6534
Comments
This is by design for the reasons you mentioned. We also don't document stuff we don't do, because the list would be pretty long. If you want this behavior you can add it to |
Fair enough, but it's not obvious that pages will search for shared files in |
FYI, I was messing around with this and did add this:
The result was pretty disappointing. The only file that worked in there was _Layout.cshtml of the 4 I was hoping to put there (Error.cshtml, _ViewImports, _ViewStart). I'm sure other partial views would also work, but I was trying to declutter the root of my /Pages folder (so that it would only have Index.cshtml in it) but for that I was unsuccessful. The Error page route naturally only worked with /Shared/Error, which wasn't what I wanted. The _ViewImports/_ViewStart files simply stopped working. Do you happen to know if there's a way to move the _ViewImports and _ViewStart files to a different, shared location? What about putting razor page Error.cshtml somewhere else but still having its URL be /Error ? Thanks! |
Both these files are based on folder hieararchy. You could move it to a folder up (to the app root), but it has to be in the hierarchy of the file you're trying to execute.
You can use |
I faced similar issue two weeks ago when I was working on theming in Bloggy specifically when I created a custom It would be nice to add |
Should be resolved as part of #6604 |
https://github.com/aspnet/Mvc/blob/a8eb5bee7023a2a5d49fcdaea0c25b3416a69211/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/RazorPagesRazorViewEngineOptionsSetup.cs
RazorPages appear to only look in /Views/Shared, not /Pages/Shared for shared view resources. Should they look in /Pages/Shared instead or as well? That seems intuitive to me, although I can understand how it could undermine the ability to use "Shared" in page-based routes. If this is by design, it should be documented.
The text was updated successfully, but these errors were encountered: