-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to GitStaticAssets/4 #33050
Move to GitStaticAssets/4 #33050
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javiercn see my questions/remarks on when MapStaticAssets
can replace UseStaticFiles
@@ -44,7 +44,7 @@ | |||
|
|||
app.UseHttpsRedirection(); | |||
|
|||
app.UseStaticFiles(new StaticFileOptions | |||
app.UseStaticFiles(new StaticFileOptions // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't use MapStaticAssets
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are compatible, but depending on how app.UseRouting
is used, one or the other will take precedence. For a simple sample like this, I would avoid updating it to use app.MapStaticAssets
and probably create a separate section for it.
app.MapStaticAssets(); // Serve files from wwwroot with MapStaticAssets | ||
app.UseStaticFiles(new StaticFileOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably shouldn't mix MapStaticAssets();
with UseStaticFiles
aspnetcore/fundamentals/static-files/samples/9.x/StaticFilesSample/Program.cs
Show resolved
Hide resolved
> [!WARNING] | ||
> `UseDirectoryBrowser` and `UseStaticFiles` can leak secrets. Disabling directory browsing in production is highly recommended. Carefully review which directories are enabled via `UseStaticFiles` or `UseDirectoryBrowser`. The entire directory and its sub-directories become publicly accessible. Store files suitable for serving to the public in a dedicated directory, such as `<content_root>/wwwroot`. Separate these files from MVC views, Razor Pages, configuration files, etc. | ||
> `UseDirectoryBrowser` and `UseStaticFiles` <!-- but not MapStaticAssets --> can leak secrets. Disabling directory browsing in production is highly recommended. Carefully review which directories are enabled via `UseStaticFiles` or `UseDirectoryBrowser`. The entire directory and its sub-directories become publicly accessible. Store files suitable for serving to the public in a dedicated directory, such as `<content_root>/wwwroot`. Separate these files from MVC views, Razor Pages, configuration files, etc. | ||
|
||
* The URLs for content exposed with `UseDirectoryBrowser` and `UseStaticFiles` are subject to the case sensitivity and character restrictions of the underlying file system. For example, Windows is case insensitive, but macOS and Linux aren't. | ||
* The URLs for content exposed with `UseDirectoryBrowser`, `UseStaticFiles`, and `MapStaticAssets` are subject to the case sensitivity and character restrictions of the underlying file system. For example, Windows is case insensitive, but macOS and Linux aren't. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javiercn please review these changes
Contributes to #32782
V9 URL
DON"T USE AUTO GENERATED, it defaults to V8, not V9
Internal previews