We already covered partial views in Chapter 8, API Controllers. Although they are a very interesting mechanism for reusing content, they historically have a problem—they could not be reused across assemblies. There has always been a way around this; the idea is to mark the view's .cshtml file as an embedded resource:
Then, we just need to use a file provider that knows how to retrieve the file contents from assembly-embedded resources. Add the Microsoft.Extensions.FileProviders.Embedded NuGet package for this example.
When registering the MVC services in ConfigureServices, we need to register another file provider, EmbeddedFileProvider, passing it to the assembly that contains the embedded resource:
services
.AddMvc()
.AddRazorOptions(options =>
{
var assembly = typeof(MyViewComponent).GetTypeInfo().Assembly;
var embeddedFileProvider = new EmbeddedFileProvider(assembly,
...