Skip to content
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

Fixes application view paths. #3087

Merged
merged 2 commits into from
Jan 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/OrchardCore/OrchardCore.Mvc.Core/ShellViewFeatureProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,29 @@ public void PopulateFeature(IEnumerable<ApplicationPart> parts, ViewsFeature fea

// Razor views are precompiled in the context of their modules, but at runtime
// their paths need to be relative to the virtual "Areas/{ModuleId}" folders.
// Note: For the app's module this folder is "Areas/{env.ApplicationName}".
foreach (var descriptor in moduleFeature.ViewDescriptors)
{
descriptor.RelativePath = '/' + module.SubPath + descriptor.RelativePath;
feature.ViewDescriptors.Add(descriptor);
}

// For the app's module we still allow to explicitly specify view paths relative to the app content root.
// So for the application's module we re-apply the feature providers without updating the relative paths.
// Note: This is only needed in prod mode if app's views are precompiled and views files no longer exist.
if (module.Name == _hostingEnvironment.ApplicationName)
{
foreach (var provider in mvcFeatureProviders)
{
provider.PopulateFeature(new ApplicationPart[] { new CompiledRazorAssemblyPart(assembly) }, moduleFeature);
jtkech marked this conversation as resolved.
Show resolved Hide resolved
}

foreach (var descriptor in moduleFeature.ViewDescriptors)
{
feature.ViewDescriptors.Add(descriptor);
}
}

moduleFeature.ViewDescriptors.Clear();
}
catch (FileLoadException)
Expand Down