-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Static files overhaul #35967
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
Static files overhaul #35967
Conversation
This reverts commit cecbd3b.
Co-authored-by: Daniel Roth <daroth@microsoft.com>
9ee972a
to
a2b8c81
Compare
|
||
:::moniker range=">= aspnetcore-6.0" | ||
|
||
*The guidance in this section applies to Razor Pages and MVC apps. For guidance that applies to Blazor Web Apps, see <xref:blazor/fundamentals/static-files#serve-files-from-multiple-locations>.* |
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.
Isn't the guidance the same? Can we remove this duplication?
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.
That's what I meant about deltas. It wasn't the same IIRC, but I'll have to look. I'll check and get back to you ... probably Tuesday morning.
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.
Removed my last response. I was incorrect about what happened.
A dev had a problem getting our main doc set guidance with the composite file provider to work in a BWA with two physical file providers (which BTW works for Blazor Server, just not BWAs) ...
I asked the dev to open a PU issue to see what we needed to do for BWAs ...
However, the issue was transferred to the docs repo without comment. I closed the transferred issue to work from the original docs issue (32891).
I presumed that what the dev did to solve the problem was a valid approach, so that's what's in the section. Instead of using two physical file providers in a composite file provider, the Blazor content pitches passing app.Environment.WebRootFileProvider
as the primary provider ...
var secondaryProvider = new PhysicalFileProvider(
Path.Combine(builder.Environment.ContentRootPath, "AdditionalStaticAssets"));
app.Environment.WebRootFileProvider = new CompositeFileProvider(
app.Environment.WebRootFileProvider, secondaryProvider);
So, we still don't have an "official" Javier ruling 👨⚖️😄 on this delta (two physical providers in a composite doesn't work in a BWA). I'll leave the current coverage as it is for now, and then we can see on technical review what to do about BWA coverage for serving files from multiple locations.
[Note in passing that what I said in my stricken comment about the main doc set's section partially focusing the Image Tag Helper in this scenario is true. When I added the Blazor article coverage, I stripped that language out, so the Blazor article section may or may not be the right pitch on how to address the multiple locations scenario for BWAs, but it is better tailored to BWAs without the Tag Helper remarks. That's something that I'd try to address in the main doc set if we shed the Blazor article section after hearing back from Javier.]
Here are the two live sections for further analysis on their deltas to see if we should try combining them in the main doc set article ...
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.
OK. I'm going to assume the differences in this content for handling static files from multiple locations in Blazor Web Apps is correct then unless @javiercn states otherwise.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
||
By default, static files are stored within the project's [web root](xref:fundamentals/index#web-root) directory. The default directory is `{CONTENT ROOT}/wwwroot`, where the `{CONTENT ROOT}` placeholder is the app's [content root](xref:fundamentals/index#content-root). Only files in the wwwroot folder will be addressable, so you don't need to worry about the rest of your code. | ||
|
||
Only files with specific file extensions mapped to supported media types are treated as static web assets. |
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 Is there more we should say about the default media type mapping for static web assets and how it can be configured?
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.
Yes, I included a section about that in my original technical description. it should be covered here if it's not covered later in the document. At leas a note/link here to where it can be configured later.
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.
I'm only going by what's here, so I need to understand where the original technical description is in order to add content ... or the content, possibly as just notes, has to be provided to me.
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.
The overall structure looks good to me. There is a fair bit of technical details that we'll need @javiercn to review.
Currently, I'm wondering why any fundamental coverage (or host/deploy ... or security) is covered in the Blazor node, given Blazor's preeminent position.
Yup, I agree we should look at what Blazor fundamentals content should really be in the top-level fundamentals docs. Let's just be careful not to overwhelm the top-level ASP.NET Core fundamentals docs with too many Blazor-specific details. We need the fundamental concepts of ASP.NET Core to be simple and straightforward.
I think it should be "Static File Middleware," not "Files" (plural). The API isn't plural.
Sounds good to me 👍
Co-authored-by: Daniel Roth <daroth@microsoft.com>
This PR is ready for @javiercn's technical review. |
`DisableBuildCompression` | Disables compression during build. | ||
`CompressDiscoveredAssetsDuringBuild` | Compresses discovered assets during build. | ||
`BrotliCompressionLevel` | Compression level for the Brotli algorithm. | ||
`LinkAlternativeRepresentationsToOriginalResource` | How to link compressed assets to original resources. |
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.
We should remove this property, I missed it when I created the list, it should not be 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.
This should ideally be on its own section as Customizing compression options
and providing examples.
|
||
Item group | Description | Metadata | ||
--- | --- | ||
`StaticWebAssetContentTypeMapping` | Maps file patterns to content types and cache headers for endpoints. | Pattern, Cache |
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.
This should be covered under a section about "adding new content type mappings at build time"
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.
I placed everything that you provided in dotnet/aspnetcore#63292. I need content or a link to additional information if I'm going to write it up (and note that @danroth27 asked me not to write up new features; leave it to the PU he instructed).
Also, I placed this section on MSBuild properties without versioning any of them. They don't all go back to 3.1, so I leave it to you guys to decide if versioning is something you want to get into the weeds with. If several came in at various times (and because I can't version individual rows of tables), this could get messy fast.
If you want to version without markdown versioning, then a table column can indicate the release that the property appeared.
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.
@guardrex @javiercn I've opened dotnet/aspnetcore#63698 to track providing the requested content. Let's merge this PR as is and add the content type mapping section separately.
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.
Ok ... I have one more pass to get the sample app out of here. It's in the samples repo now. I didn't do it yet because I didn't want to clutter the diff. I'll take care of it by EOD.
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.
<ItemGroup>
<StaticWebAssetContentTypeMapping Include="image/bmp" Cache="<<Cache-Header-To-Use-For-Non-Fingerprinted-Endpoints>>" Pattern="*.bmp" />
</ItemGroup>
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.
Few comments, otherwise looks good.
@danroth27 ... Ok, those two are done, and the samples are now only in the samples repo, not here. I think we're good 👍. I'll see it live tomorrow morning and look for any lingering 😈. |
Fixes #35810
Fixes #35833
After Javier technical review, I'll ping Wade and Tom.
Notes
dotnet/AspNetCore.Docs.Samples
repo. The sample apps were placed in that repo on Add static files sample apps AspNetCore.Docs.Samples#282. I'll delete them from this repo on this PR after reviews to avoid cluttering the diff.Internal previews