Skip to content

Instantly share code, notes, and snippets.

@cwe1ss
Created May 10, 2016 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwe1ss/d44f22a4522b74d9c54303d3e417887b to your computer and use it in GitHub Desktop.
Save cwe1ss/d44f22a4522b74d9c54303d3e417887b to your computer and use it in GitHub Desktop.
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