-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Layout not rendered via ViewStart.cshtml: Question on Razor View discovery in .Net Core preview 1 #6448
Comments
Could you share a repro app (preferably as a GitHub repo)? There haven't been too many changes to the |
@pranavkm https://github.com/Ponant/LayoutFeature . |
@pranavkm is there a bug here? If we're not compatible with 1.1 then this is bad. |
It seems that Scott's NuGet is searching in the correct locations
But somehow the program fails to load them unless I explicitly call them from the Home/Index View |
@rynowak - we missed a path normalization ( |
So it sounds like no tooling impact right? This is just in the pieces that resolve the layout? |
Yup. It's isolated to the view engine + view location expanders. |
@Ponant - we're close to signing off on our preview2 work, and its unlikely we would reset for a bug fix at this point. This should be available for 2.0.0 release though. public class FixBackSlashViewLocationExpander : IViewLocationExpander
{
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
foreach (var path in viewLocations)
{
yield return path.Replace('\\', '/');
}
}
public void PopulateValues(ViewLocationExpanderContext context){}
} |
@pranavkm , your workaround should work for preview 1 also, or only preview 2? Thanks |
Both of those releases. |
OK I will try this in the meanwhile. |
To complete @pranavkm workaround, one needs to configure services as such
|
Hi,
I was using a simple but otherwise great library in .Net Core 1.1 by Scott Allen https://github.com/OdeToCode/AddFeatureFolders/ that allows one to put controllers and views in a Feature-folder architecture. The View discovery of this NuGet was working perfectly fine in 1.1, but implementing this architecture in .Net Core 2.0 Preview 1 makes the Layout View via ViewStart.cshtml not discoverable. I tested this with an empty template from preview 1 with the minimum required (one controller one view, one shared folder hosting a layout, and one viewstart and viewimport). The workaround is to call Layout="_Layout" from the view to be rendered in RenderBody() (e.g. Index view of a Home controller) OdeToCode/AddFeatureFolders#16.
Thus my question: is there any change that occurred to the view engine since 1.1 you can point me to and that could be at the origin of this malfunctioning? I have seen some comments but they seem to concern Razor pages only
#6308
#6428
The text was updated successfully, but these errors were encountered: