To tell AspNetStatic which routes to process, you must implement or configure an IStaticResourcesInfoProvider. You can do this by creating an instance of StaticResourcesInfoProvider (which derives from StaticResourcesInfoProviderBase) and populating its resource collections.
Resource Types
PageResource: For HTML pages. You can specify the Route and an optional OutFile or Query string.CssResource: For CSS files. Supports an OptimizationType property.JsResource: For JavaScript files.BinResource: For binary assets like images or favicons.
Registration
Register the provider in your DI container (typically in Program.cs) as a singleton.
// Example 1: Using extension methods from AspNetStaticContrib
builder.Services.AddSingleton<IStaticResourcesInfoProvider>(
new StaticResourcesInfoProvider()
.AddAllProjectRazorPages(builder.Environment)
.AddAllWebRootContent(builder.Environment));
// Example 2: Manual configuration of specific routes
builder.Services.AddSingleton<IStaticResourcesInfoProvider>(
new StaticResourcesInfoProvider(
new []
{
new PageResource("/"),
new PageResource("/privacy"),
new PageResource("/blog/articles/posts/1") { OutFile = "blog/post-1.html" },
new PageResource("/blog/articles/posts/2") { OutFile = "blog/post-2-dark.html", Query = "?theme=dark" },
new CssResource("/bootstrap/bootstrap.min.css") { OptimizationType = OptimizationType.None },
new CssResource("/site.css"),
new JsResource("/site.js"),
new BinResource("/favicon.png")
}));