Have a look at how PinpointTownes implemented this in his OpenIddict project.
You can use the UseStaticFiles
call with a EmbeddedFileProvider
. It's part of the rc1-final package, as you can see here. The relevant code is found on GitHub.
Just for future readers:
app.UseStaticFiles(new StaticFileOptions {
FileProvider = new EmbeddedFileProvider(
assembly: Assembly.Load(new AssemblyName("OpenIddict.Assets")),
baseNamespace: "OpenIddict.Assets")
});
OpenIddict.Assets
is the assembly/project name that contains the static resources.
Update:
After digging a bit through the source and finding the right repository, there is also a PhysicalFileProvider
you may be able to use instead of packing it into the assembly and point to an arbitrary folder on the file system.
app.UseStaticFiles(new StaticFileOptions {
FileProvider = new PhysicalFileProvider("/path/to/shared/staticfiles")
});
Update 2:
Just for the sake of completeness, there is also a CompositeFileProvider
which you could use to have multiple IFileProviders
to create some kind of virtual file system structure, i.e. if the file is not found in the PhysicalFileProvider
given location, load it from an EmbeddedFileProvider
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…