I want to share the layout (Header, Navigation and Footer Razor views) across multiple ASP.NET MVC projects. How can I do that?
Can I create a custom NuGet package t
There are new options (IMHO) better available.
I would take advantage of organizing it as Feature splices in ASP MVC Core, this would save a lot of time down the road, I would recommend it in 2 steps.
First, organize/put it an area called Features splices MSDN ref. wire it up as in the article and well explained.
// you're telling ASP that you've other Feature areas that it should look
public IEnumerable ExpandViewLocations(ViewLocationExpanderContext context,
IEnumerable viewLocations)
{
// Error checking removed for brevity
var controllerActionDescriptor = context.ActionContext.ActionDescriptor as ControllerActionDescriptor;
string featureName = controllerActionDescriptor.Properties["feature"] as string;
foreach (var location in viewLocations)
{
yield return location.Replace("{3}", featureName);
}
}
Second, embed Features in a
Shared project or Portable Libraries. I have attached links on
how to do this from R. Williams and MSDN.
In summary, since you already have it in a common area consider it to be a feature and embed it inside a portable lib or a Shared Project. A nice article by R. Williams.