Created
February 12, 2018 10:05
-
-
Save miroslavradojevic/befbc6a141f46296f8dd509946de9835 to your computer and use it in GitHub Desktop.
Add file server from relative path, named wwwroot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Startup { | |
public void Configuration(IAppBuilder app){ | |
if (!Directory.Exists("wwwroot")) Directory.CreateDirectory("wwwroot"); | |
var physicalFileSystem = new PhysicalFileSystem("./wwwroot"); | |
// file server options | |
var options = new FileServerOptions | |
{ | |
EnableDefaultFiles = true, | |
FileSystem = physicalFileSystem, // register file system | |
EnableDirectoryBrowsing = false | |
}; | |
options.StaticFileOptions.FileSystem = physicalFileSystem; | |
options.StaticFileOptions.ServeUnknownFileTypes = true; | |
options.DefaultFilesOptions.DefaultFileNames = new[] { "index.html" }; | |
//app.Use<DefaultFileRewriterMiddleware>(physicalFileSystem); // middleware to direct non-existing file URLs to index.html | |
app.UseFileServer(options); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment