Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have racked my brains on this issue for a whole day but seem to have no success on this. Previously being on .NET 8, I was able to serve a WASM web app for local dev with precompressed Brotli files with extensions like .wasm.br, .js.br, .data.br (Unity webgl artifacts) without a problem using IIS Express with the following web.config (see below). As expected, all of the above precompressed files would be served with the expected content-type and encoding.
Now after upgrading to .NET 10, the file wwwroot/assets/webgl/Build.framework.js.br returns a 200 with the correct raw data (brotli-encoded JS), with content-type: text/javascript (correct) and content-encoding: gzip (wrong). Because of the wrong encoding returned, the browser does not automatically decode the brotli compression to show a normal JS file (which is what my application expects).
All other files with .wasm.br or .data.br seem to correctly pass through the PreCompressedBrotli condition on IIS. I sanity-checked it by changing it to something else like value="foo" and it reflects when fetching said resources.
Interestingly enough, if I specify a non-existent filename like Foo.framework.js.br, the response is (obviously) 404 with the correct br encoding, implying that that filename does go through the intended rewrite section.
Is there a something new on .NET 10 that changes how static files are served?
<!-- web.config -->
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<outboundRules rewriteBeforeCache="false">
<rule name="Set content type of compressed JS" preCondition="PreCompressedJs">
<match serverVariable="RESPONSE_CONTENT_TYPE" pattern="^$" />
<action type="Rewrite" value="text/javascript" />
</rule>
<rule name="Set content type of compressed WASM" preCondition="PreCompressedWasm">
<match serverVariable="RESPONSE_CONTENT_TYPE" pattern="^$" />
<action type="Rewrite" value="application/wasm" />
</rule>
<rule name="Set content type of compressed data" preCondition="PreCompressedData">
<match serverVariable="RESPONSE_CONTENT_TYPE" pattern="^$" />
<action type="Rewrite" value="application/octet-stream" />
</rule>
<rule name="Set content encoding of brotli files" preCondition="PreCompressedBrotli">
<match serverVariable="RESPONSE_CONTENT_ENCODING" pattern="^$" />
<action type="Rewrite" value="br" />
</rule>
<preConditions>
<preCondition name="PreCompressedJs">
<add input="{PATH_INFO}" pattern=".*\.js\.br"/>
</preCondition>
<preCondition name="PreCompressedWasm">
<add input="{PATH_INFO}" pattern=".*\/assets\/webgl\/.*\/.*.wasm\.br"/>
</preCondition>
<preCondition name="PreCompressedData">
<add input="{PATH_INFO}" pattern=".*\/assets\/webgl\/.*\/.*.data\.br"/>
</preCondition>
<preCondition name="PreCompressedBrotli">
<add input="{PATH_INFO}" pattern=".*\.br" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
.NET 10.0.10
Anything else?
No response
Activity
oroztocil commentedon Sep 2, 2026
Hi @jonganej. Sorry for the late response, we did not see the issue before due to a triaging mistake.
The change in behavior that you observe follows from a change made in .NET 9, where the Blazor WebAssembly dev server started serving
wwwrootthrough static web asset endpoints (MapStaticAssets) instead of the static file middleware. A side effect is that.brfiles now get a content type assigned, where previously they got none. The SDK maps*.js.brto the content type of the decompressed payload, so your file is now served asContent-Type: text/javascript.By default, IIS Express has
text/*enabled in itshttpCompressionconfiguration, while*/*is disabled. So once the response is labeledtext/javascript, IIS dynamic compression kicks in, gzips your already brotli encoded bytes, and setsContent-Encoding: gzip. Your outbound rule only fires when that header is empty, so it never runs. On the other hand,.wasm.brand.data.brare labeledapplication/wasmandapplication/octet-stream, which fall through to the disabled*/*entry, so IIS leaves them alone and your rule applies.To work around this, the following methods should help you.
a) Turn off dynamic compression just for the folder holding your precompressed assets. Your existing rules keep working, and the rest of the app still gets compressed normally:
b) Or turn it off for the whole app, if you do not need dynamic compression anywhere:
c) Or place the uncompressed
Build.framework.jsnext toBuild.framework.js.br. That makes the SDK recognise the.bras a compressed representation and emitContent-Encoding: britself, which in turn stops IIS from compressing it. With this in place your outbound rules become unnecessary and can be removed entirely. The tradeoff is that you are shipping both copies, which may not be worth it for large Unity artifacts.The last workaround is based on a quirk that we should probably investigate as an SDK bug: When only
Foo.js.brexists and there is no uncompressedFoo.jsnext to it, the generated endpoint getsContent-Type: text/javascriptbut noContent-Encoding: br. If both files are present thebrheader is emitted correctly.dotnet-policy-service commentedon Sep 2, 2026
Hi @jonganej. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
dotnet-policy-service commentedon Sep 25, 2026
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
See our Issue Management Policies for more information.