I watched over the Internet, and I still had no luck, so I ask. I have a WEB API 4.6 project, which will also contain an angularjs2 application. I installed static files to use as follows:
var physicalFileSystem = new PhysicalFileSystem(@".\wwwroot\"); var options = new FileServerOptions { EnableDefaultFiles = true, FileSystem = physicalFileSystem, }; var contentTypes = new FileExtensionContentTypeProvider(); options.StaticFileOptions.FileSystem = physicalFileSystem; options.StaticFileOptions.ServeUnknownFileTypes = true; options.StaticFileOptions.ContentTypeProvider = contentTypes; options.DefaultFilesOptions.DefaultFileNames = new[] { "index.html" }; options.EnableDirectoryBrowsing = true; app.UseFileServer(options);
index.html is served when index.html tries to extract all the files (.css.js), a 404 error appears on the console. I turned on directory browsing and I see that the files are there.
Rafael Valle
source share