aspnet / StaticFiles

[Archived] Middleware for handling requests for file system resources including files and directories. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
114 stars 72 forks source link

DefaultFilesMiddleware in conjunction with EmbeddedFileProvider and subpaths #164

Closed avanderhoorn closed 7 years ago

avanderhoorn commented 7 years ago

The behaviour of DefaultFilesMiddleware doesn't seem quite right when used in conjunction with EmbeddedFileProvider and subpaths. Specifically if my url was "localhost:3000/static/client/" and my EmbeddedFileProviders baseNamespace was setup to point to static, I would expect that translate through to and look for "localhost:3000/static/client/index.html"... this is not the case however.

Specifically, in scenarios where the EmbeddedFileProvider has been setup as described, the DefaultFilesMiddleware fails to find a match as the subpath.Value (in the first link below below) is equal to /client/ which causes the EmbeddedFileProvider to short circuit (in the second link below):

Based on the comment in GetDirectoryContents, I understand why this is the case - // Non-hierarchal. but in the context of how this is used within DefaultFilesMiddleware it seems like the wrong decision, or at the very least, very limiting - as the way the logic is setup, it can only ever support matching defaults at the root level.

I can think of a few different solutions to this problem, but before putting further energy into this, I wanted to see if there is any desire to support this use case?

Tratcher commented 7 years ago

Yes, this is a known limitation of EmbeddedFileProvider and that's where any enhancements would need to be made.

avanderhoorn commented 7 years ago

I'm happy to bring this up there, but before putting further energy into this, I wanted to see if there is any desire to support this use case?

Tratcher commented 7 years ago

It has come up before, though I can't find the thread at the moment. Yes, it would be nice to make it work eventually.

muratg commented 7 years ago

This issue was moved to aspnet/FileSystem#255