I want to know what is the difference between these two blocks of code for OWIN.
It seems to me that they are doing the same job.
1.
string root = AppDomain.CurrentDomain.BaseDirectory;
var physicalFileSystem = new PhysicalFileSystem(Path.Combine(root, "wwwroot"));
var options = new FileServerOptions
{
RequestPath = PathString.Empty,
EnableDefaultFiles = true,
FileSystem = physicalFileSystem
};
options.StaticFileOptions.FileSystem = physicalFileSystem;
options.StaticFileOptions.ServeUnknownFileTypes = false;
app.UseFileServer(options);
2.
app.UseStaticFiles("wwwroot");
IAppBuilder.UseFileserver combines UseStaticFiles UseDefaultFiles, but not UseDirectorybrowser by default.
That means:
app.UseFileServer(enableDirectoryBrowsing: true);
enables all of the above, while
app.UseFileServer();
only enables static files and default files, but not directory browsing.
In reverse that means, that IAppBuilder.UseStaticFiles only enables the webserver to serve static files, but does not make any assumptions about default documents or directory browsing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With