Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class FeatureFolderViewLocationExpander : IViewLocationExpander
{
public void PopulateValues(ViewLocationExpanderContext context)
{
/* no-op */
}
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
// {0} - Action Name
// {1} - Controller Name
// {2} - Area name
object area;
if (context.ActionContext.RouteData.Values.TryGetValue("area", out area))
{
yield return "/Areas/{2}/{1}/{0}.cshtml";
yield return "/Areas/{2}/Shared/{0}.cshtml";
yield return "/Areas/Shared/{0}.cshtml";
}
else
{
yield return "/Features/{1}/{0}.cshtml";
yield return "/Features/Shared/{0}.cshtml";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment