You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WASM Deep Linking on IIS Not Working with Default web.config #22227
The rest of the default web.config doesn't look correct, at least not on NET10 WASM builds. There are no _compressed_br and _compressed_gz folders in the published output.
This is what I am currently using for my web.config. If you want me to PR it or adjust some things let me know. Note that a new RESPONSE_X_COMPRESSION_APPLIED server var is used so that SPA paths like app.com/documents/asdf.br don't get a content-encoding applied to them.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrorsmode="Off"/>
</system.web>
<system.webServer>
<!-- Disable compression as we're doing it through pre-compressed files -->
<urlCompressiondoStaticCompression="false"doDynamicCompression="false"dynamicCompressionBeforeCache="false" />
<rewrite>
<rules>
<rulename="Lookup for pre-compressed brotli file"stopProcessing="true">
<matchurl="(.*)$"/>
<conditions>
<!-- Match brotli requests -->
<addinput="{HTTP_ACCEPT_ENCODING}"pattern="br" />
<!-- Don't rewrite requests that already end with .br -->
<addinput="{REQUEST_URI}"pattern="\.br$"negate="true" />
<!-- Check if the pre-compressed .br file exists on the disk -->
<addinput="{REQUEST_FILENAME}.br"matchType="IsFile"negate="false" />
</conditions>
<serverVariables>
<setname="RESPONSE_X_COMPRESSION_APPLIED"value="br" />
</serverVariables>
<actiontype="Rewrite"url="{R:0}.br" />
</rule>
<rulename="Lookup for pre-compressed gzip file"stopProcessing="true">
<matchurl="(.*)$"/>
<conditions>
<!-- Match gzip requests -->
<addinput="{HTTP_ACCEPT_ENCODING}"pattern="gzip" />
<!-- Don't rewrite requests that already end with .gz -->
<addinput="{REQUEST_URI}"pattern="\.gz$"negate="true" />
<!-- Check if the pre-compressed .gz file exists on the disk -->
<addinput="{REQUEST_FILENAME}.gz"matchType="IsFile"negate="false" />
</conditions>
<serverVariables>
<setname="RESPONSE_X_COMPRESSION_APPLIED"value="gzip" />
</serverVariables>
<actiontype="Rewrite"url="{R:0}.gz" />
</rule>
<rulename="SPA fallback - serve app root for client routes"stopProcessing="true">
<matchurl=".*" />
<conditions>
<!-- Serve existing files and directories as-is -->
<addinput="{REQUEST_FILENAME}"matchType="IsFile"negate="true" />
<addinput="{REQUEST_FILENAME}"matchType="IsDirectory"negate="true" />
</conditions>
<serverVariables>
<setname="RESPONSE_X_SPA_FALLBACK"value="true" />
</serverVariables>
<actiontype="Rewrite"url="/" />
</rule>
</rules>
<outboundRules>
<rulename="Adjust content encoding for gzip pre-compressed files">
<matchserverVariable="RESPONSE_CONTENT_ENCODING"pattern="" />
<conditions>
<addinput="{RESPONSE_X_COMPRESSION_APPLIED}"pattern="gzip" />
</conditions>
<actiontype="Rewrite"value="gzip"/>
</rule>
<rulename="Adjust content encoding for brotli pre-compressed files">
<matchserverVariable="RESPONSE_CONTENT_ENCODING"pattern="" />
<conditions>
<addinput="{RESPONSE_X_COMPRESSION_APPLIED}"pattern="br" />
</conditions>
<actiontype="Rewrite"value="br"/>
</rule>
<!-- Cache control: SPA fallback responses must always revalidate -->
<rulename="Cache control for SPA fallback"stopProcessing="true">
<matchserverVariable="RESPONSE_CACHE_CONTROL"pattern=".*" />
<conditions>
<addinput="{RESPONSE_X_SPA_FALLBACK}"pattern="true" />
</conditions>
<actiontype="Rewrite"value="no-cache"/>
</rule>
<!-- Skip additional cache control for non-2xx responses -->
<rulename="Skip cache control for error responses"stopProcessing="true">
<matchserverVariable="RESPONSE_STATUS"pattern="^[^2]" />
<actiontype="None" />
</rule>
<!-- Cache control: /_framework/dotnet.js is not fingerprinted, must always revalidate --><!-- https://github.com/dotnet/aspnetcore/issues/61425#issuecomment-3815538132 -->
<rulename="Cache control for dotnet.js"stopProcessing="true">
<matchserverVariable="RESPONSE_CACHE_CONTROL"pattern=".*" />
<conditions>
<addinput="{REQUEST_URI}"pattern="^/_framework/dotnet\.js(\.br|\.gz)?$" />
</conditions>
<actiontype="Rewrite"value="no-cache"/>
</rule>
<!-- Cache control: other /_framework files are fingerprinted, can cache forever -->
<rulename="Cache control for framework files"stopProcessing="true">
<matchserverVariable="RESPONSE_CACHE_CONTROL"pattern=".*" />
<conditions>
<addinput="{REQUEST_URI}"pattern="^/_framework/" />
</conditions>
<actiontype="Rewrite"value="public, max-age=31536000, immutable"/>
</rule>
<!-- Cache control: /package_* folders are fingerprinted, can cache forever -->
<rulename="Cache control for package files"stopProcessing="true">
<matchserverVariable="RESPONSE_CACHE_CONTROL"pattern=".*" />
<conditions>
<addinput="{REQUEST_URI}"pattern="^/package_" />
</conditions>
<actiontype="Rewrite"value="public, max-age=31536000, immutable"/>
</rule>
<!-- Cache control: Root SPA entry files must always revalidate -->
<rulename="Cache control for root files"stopProcessing="true">
<matchserverVariable="RESPONSE_CACHE_CONTROL"pattern=".*" />
<conditions>
<addinput="{REQUEST_URI}"pattern="^/[^/]*$" />
</conditions>
<actiontype="Rewrite"value="no-cache"/>
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
In your azure static web app config file I see you have a 1 hour max-age set on non-package/TTF files. I can adjust the above to match that before I PR if you prefer that. I just prefer instant updates for visitors and it's only a few files that end up being forced to revalidate on initial load so it's practically inconsequential.
Isn't the "route": "/*.ttf" redundant? The TTF files should be in the package folder, no?
Is there a reason you're not marking fingerprinted _framework files as immutable?
Is there a reason you're not marking fingerprinted _framework files as immutable?
Mainly because this file it's been used less and it got missed in the update of the templates. For the dotnet.json, the latest build of the bootstrapper will also fingerprint that file, so it avoids incorrect reloads on app updates.
Isn't the "route": "/*.ttf" redundant? The TTF files should be in the package folder, no?
For this part, I'm not sure why this was added this way. It most likely is a old registration related to versions of uno that weren't supporting fonts as assets. It's supported now, so we should be able to remove this.
For the file in itself, it's looking good for a PR in uno.templates, but you might want to specify the wasm mime types, so that proper stream loading can happen in browsers (that is unless the IIS environment already provides it).
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
Still planning on publishing a PR for this, just have to resolve an issue where this doesn't always work reliably, either because a file that should be fingerprinted doesn't get fingerprinted or something else odd is going on (i.e. with service worker) that causes it to fail loading after a republish. I have a manual workaround I have been using for this but I will investigate later this week before I submit the final PR.
Alright, sorry for the delay...pinning down the root cause of the caching issues was a bit painful, but I think I found the problem.
After publishing a build where only C# or XAML changed, the package_* fingerprint stays the same. That part is actually by design as far as I can tell, since the hash is computed by ShellTask.GeneratePackageFolder() over the static web content only, and managed code lives under _framework with its own fingerprinting. The problem is that returning visitors then end up booting the old version of the app, or a broken mix of old and new, until I force the fingerprint to change (my workaround has been bumping a counter in a file under /Assets just to poke the hash).
The root cause: uno-config.js lives inside the fingerprinted package_* folder, but it gets rewritten after the fingerprint is computed. The _UnoUpdateDotnetJsFingerprintPublishOutput target (in build/Uno.Wasm.Bootstrap.targets, runs AfterTargets="Publish" when WasmFingerprintDotnetJs is enabled) locates the actual dotnet.<fingerprint>.js produced by that publish and patches package_X/uno-config.js in place to reference it. So when only managed code changes, you get the same folder name with different contents inside it. A returning browser serves its year-old cached copy of package_X/uno-config.js, which points at the previous dotnet.<oldfingerprint>.js, and from there the whole old boot chain loads (or 404s if the old files are gone). The target even deletes the stale .gz/.br copies of uno-config.js after patching, so the file being mutated post-packaging is a known situation, but the cache invariant it breaks doesn't seem to have been considered: a fingerprinted-immutable folder must never contain a file that's written after the fingerprint is computed.
uno-config.js is effectively a boot manifest whose content depends on the managed/native build output, so it can't live in an immutable cache class keyed off a hash that excludes that output. The cleanest fix seems to be moving it out of the package_* folder to the wwwroot root next to index.html, where the no-cache policy applies. It's a few hundred bytes, so caching it forever has no real value anyway, and this mirrors how the .NET WASM SDK treats its own boot config. There's already a fallback lookup for a root-level uno-config.js in the targets, so some of the plumbing exists. The alternative would be to finalize uno-config.js before the package hash is computed (or re-fingerprint and rename the folder after patching), but that looks messier since the folder name is already baked into the root files by then.
Let me know if I can PR a fix along with updated web.config fixes.
(this bug was also causing problems when locally running WASM tests in the Uno repo, making me go in loops trying to figure out why a bug I fixed still wasn't fixed after I thought I fixed it, until I realized what was going on, lol)
Activity
MartinZikmund commentedon Jan 12, 2026
That is a good find. I think we could include it in the default template for WASM @jeromelaban?
jeromelaban commentedon Jan 13, 2026
I think so yes, let's include it.
mikernet commentedon Jan 29, 2026
The rest of the default
web.configdoesn't look correct, at least not on NET10 WASM builds. There are no_compressed_brand_compressed_gzfolders in the published output.mikernet commentedon Jan 29, 2026
It would probably also be good to set some cache control behavior in there.
mikernet commentedon Jan 29, 2026
This is what I am currently using for my web.config. If you want me to PR it or adjust some things let me know. Note that a new
RESPONSE_X_COMPRESSION_APPLIEDserver var is used so that SPA paths likeapp.com/documents/asdf.brdon't get a content-encoding applied to them.mikernet commentedon Jan 29, 2026
In your azure static web app config file I see you have a 1 hour max-age set on non-package/TTF files. I can adjust the above to match that before I PR if you prefer that. I just prefer instant updates for visitors and it's only a few files that end up being forced to revalidate on initial load so it's practically inconsequential.
Isn't the
"route": "/*.ttf"redundant? The TTF files should be in the package folder, no?Is there a reason you're not marking fingerprinted
_frameworkfiles as immutable?jeromelaban commentedon Jan 30, 2026
Mainly because this file it's been used less and it got missed in the update of the templates. For the dotnet.json, the latest build of the bootstrapper will also fingerprint that file, so it avoids incorrect reloads on app updates.
For this part, I'm not sure why this was added this way. It most likely is a old registration related to versions of uno that weren't supporting fonts as assets. It's supported now, so we should be able to remove this.
For the file in itself, it's looking good for a PR in uno.templates, but you might want to specify the wasm mime types, so that proper stream loading can happen in browsers (that is unless the IIS environment already provides it).
Thanks!
mikernet commentedon Feb 1, 2026
@jeromelaban
Ah yeah, I'll leave whatever is in there now for the MIME types. we have those registered at the server level so it wasn't needed.
github-actions commentedon Jun 2, 2026
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
mikernet commentedon Jun 2, 2026
Still planning on publishing a PR for this, just have to resolve an issue where this doesn't always work reliably, either because a file that should be fingerprinted doesn't get fingerprinted or something else odd is going on (i.e. with service worker) that causes it to fail loading after a republish. I have a manual workaround I have been using for this but I will investigate later this week before I submit the final PR.
mikernet commentedon Aug 21, 2026
@jeromelaban @MartinZikmund
Alright, sorry for the delay...pinning down the root cause of the caching issues was a bit painful, but I think I found the problem.
After publishing a build where only C# or XAML changed, the
package_*fingerprint stays the same. That part is actually by design as far as I can tell, since the hash is computed byShellTask.GeneratePackageFolder()over the static web content only, and managed code lives under_frameworkwith its own fingerprinting. The problem is that returning visitors then end up booting the old version of the app, or a broken mix of old and new, until I force the fingerprint to change (my workaround has been bumping a counter in a file under/Assetsjust to poke the hash).The root cause:
uno-config.jslives inside the fingerprintedpackage_*folder, but it gets rewritten after the fingerprint is computed. The_UnoUpdateDotnetJsFingerprintPublishOutputtarget (inbuild/Uno.Wasm.Bootstrap.targets, runsAfterTargets="Publish"whenWasmFingerprintDotnetJsis enabled) locates the actualdotnet.<fingerprint>.jsproduced by that publish and patchespackage_X/uno-config.jsin place to reference it. So when only managed code changes, you get the same folder name with different contents inside it. A returning browser serves its year-old cached copy ofpackage_X/uno-config.js, which points at the previousdotnet.<oldfingerprint>.js, and from there the whole old boot chain loads (or 404s if the old files are gone). The target even deletes the stale.gz/.brcopies ofuno-config.jsafter patching, so the file being mutated post-packaging is a known situation, but the cache invariant it breaks doesn't seem to have been considered: a fingerprinted-immutable folder must never contain a file that's written after the fingerprint is computed.uno-config.jsis effectively a boot manifest whose content depends on the managed/native build output, so it can't live in an immutable cache class keyed off a hash that excludes that output. The cleanest fix seems to be moving it out of thepackage_*folder to the wwwroot root next toindex.html, where the no-cache policy applies. It's a few hundred bytes, so caching it forever has no real value anyway, and this mirrors how the .NET WASM SDK treats its own boot config. There's already a fallback lookup for a root-leveluno-config.jsin the targets, so some of the plumbing exists. The alternative would be to finalizeuno-config.jsbefore the package hash is computed (or re-fingerprint and rename the folder after patching), but that looks messier since the folder name is already baked into the root files by then.Let me know if I can PR a fix along with updated web.config fixes.
mikernet commentedon Aug 21, 2026
(this bug was also causing problems when locally running WASM tests in the Uno repo, making me go in loops trying to figure out why a bug I fixed still wasn't fixed after I thought I fixed it, until I realized what was going on, lol)
mikernet commentedon Sep 21, 2026
The
web.configrework is up as unoplatform/uno.templates#2267, and theuno-config.jsfingerprint problem described above is now tracked separately in unoplatform/Uno.Wasm.Bootstrap#1076 since the code lives in the bootstrapper.