Search code examples
aspnetboilerplate

How to correctly implement EmbeddedResource _ViewImports & _ViewStart in plugins


I'd like to create embedded _ViewImports file that sets usings, inheritance (to change localization source) for views specific to the plugin. Problem is when I include embedded views like this

Configuration.EmbeddedResources.Sources.Add(
    new EmbeddedResourceSet(
        "/Views/",
        Assembly.GetExecutingAssembly(),
        "MyPlugin.Web.Views"
    )
);

Then _ViewImports.cshtml from this plugin's View folder overrides all others for the entire site. What do I need to do to scope it only to views found in the plugin?


Solution

  • Asp.net core has already a feature Areas

    You need to use Area to make it scoped!