Skip to content
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

Merged
merged 16 commits into from
Jul 30, 2024
Merged

Move to GitStaticAssets/4 #33050

merged 16 commits into from
Jul 30, 2024

Conversation

Rick-Anderson
Copy link
Contributor

@Rick-Anderson Rick-Anderson commented Jul 11, 2024

Contributes to #32782

V9 URL

DON"T USE AUTO GENERATED, it defaults to V8, not V9


Internal previews

📄 File 🔗 Preview link
aspnetcore/fundamentals/static-files.md Static files in ASP.NET Core

Copy link
Contributor Author

@Rick-Anderson Rick-Anderson left a 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 //
Copy link
Contributor Author

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.

Copy link
Member

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.

Comment on lines 386 to 387
app.MapStaticAssets(); // Serve files from wwwroot with MapStaticAssets
app.UseStaticFiles(new StaticFileOptions
Copy link
Contributor Author

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

@Rick-Anderson Rick-Anderson changed the title Move to GitStaticAssets Move to GitStaticAssets/4 Jul 23, 2024
Comment on lines 275 to +278
> [!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.
Copy link
Contributor Author

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

@Rick-Anderson Rick-Anderson merged commit 68989b2 into main Jul 30, 2024
3 checks passed
@Rick-Anderson Rick-Anderson deleted the MapStaticAssets/update/rick branch July 30, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants