Skip to content

fix(wasm): Rework IIS web.config for deep links, compression, caching and MIME types - #2267

Open
mikernet wants to merge 2 commits into
unoplatform:mainfrom
mikernet:dev/mikernet/iis-webconfig
Open

mikernet wants to merge 2 commits into
unoplatform:mainfrom
mikernet:dev/mikernet/iis-webconfig

Conversation

@mikernet

@mikernet mikernet commented Sep 21, 2026 •

Copy link
Copy Markdown

GitHub Issue (If applicable): closes #2266, closes unoplatform/uno#22227

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

The web.config in the WebAssembly template has no SPA fallback, so a deep link to a client route on IIS returns a 404. The pre-compressed file lookup also targets _compressed_br and _compressed_gz folders that the current publish output does not contain, so IIS serves everything uncompressed. No cache policy is defined, and the MIME table only covers a few types.

What is the new behavior?

  • Requests for a path that is not an existing file or directory are rewritten to index.html.
  • A missing file under /_framework/ or /package_* still fails with a 404 instead of being served the app root, and that 404 is marked no-store so a CDN or browser never caches the failure. Detection is done with a server variable set by the inbound rule, because URL Rewrite exposes no response status to outbound rules.
  • Pre-compressed files are looked up next to the original as .br and .gz, matching the current publish output. A server variable set by the inbound rule drives the Content-Encoding outbound rule, so a client route that happens to end in .br or .gz is not mislabelled.
  • Fingerprinted files under /_framework/ and /package_* are served with public, max-age=31536000, immutable; everything else, including SPA fallbacks, is served with no-cache.
  • The file works from the site root, from a plain subfolder, and from an IIS sub-application: rewrite rules match the folder-relative URL and the fallback rewrites to a relative index.html.
  • The MIME table covers the types a typical app publishes (application files, .NET runtime files, fonts, images, media). Each base type is removed before being added so the file loads regardless of what the server already defines, and every type the .NET SDK pre-compresses gets .gz and .br entries mapped to the original type so .wasm responses keep application/wasm and module scripts keep application/javascript.

Validated with IIS Express 10 (URL Rewrite 2.1) against a net10.0-browserwasm publish of the Uno SamplesApp, with no MIME types defined at server level, in root, subfolder, and sub-application layouts, each in detailed-error mode and with a file-based custom 404 page (the mode remote clients get from a default IIS install). A full sweep requesting every published file with br, gzip, and no encoding (21,735 requests) returned the expected encoding, byte length, content type, and cache policy for every file of a listed type; the only failures were 404s for build leftovers with unlisted extensions. Spot checks:

Request Result
/ with br 200, text/html, no-cache, uncompressed (index.html served directly)
/index.html with gzip 200, text/html, Content-Encoding: gzip, no-cache
/_framework/dotnet.native.wasm with br 200, application/wasm, Content-Encoding: br, immutable
/_framework/icudt_CJK.dat with gzip 200, application/octet-stream, Content-Encoding: gzip, immutable
/package_<hash>/Uno.Wasm.js with gzip, deflate, br 200, application/javascript, Content-Encoding: br, immutable
/package_<hash>/.../OpenSans-Bold.ttf with br 200, font/ttf, Content-Encoding: br, immutable
/some/deep/link with br 200, index.html, no-cache, no Content-Encoding
/documents/asdf.br with br 200, index.html, no-cache, no Content-Encoding
/_framework/nope.js 404, no-store with a custom error page, private with detailed errors
/package_<hash>/nope.png 404, same as above

PR Checklist

Please check if your PR fulfills the following requirements:

  • Associated with an issue (GitHub or internal)

Other information

The package_* immutable cache policy matches the existing staticwebapp.config.json. Note that uno-config.js inside package_* is rewritten after the package fingerprint is computed (see the discussion on the linked issue), which affects both files equally; a follow-up will address that separately.

Internal Issue (If applicable):

The template web.config had no SPA fallback, so a deep link to a
client route returned a 404 (#22227 in unoplatform/uno). It also
looked for pre-compressed files under _compressed_br and
_compressed_gz, folders the current publish output no longer has, so
IIS served everything uncompressed.

Requests for a path with no matching file or directory now serve
index.html, except under _framework and package_* where a missing
file must still fail and is marked no-store. Pre-compressed files are looked up next to the
original as .br and .gz, with a server variable driving the
Content-Encoding so that a client route ending in .br or .gz is not
mislabelled. Fingerprinted files under _framework and package_* are
cached as immutable and everything else revalidates.

MIME entries are removed before being added so the file loads on any
server, whichever of these types it already defines, and every
pre-compressed extension is mapped to its original type so the
webassembly and module script responses keep their types.
The SPA fallback rewrote to the site-absolute /index.html and the
cache rules matched REQUEST_URI anchored at the site root, so a
publish dropped into a subfolder or sub-application served the parent
site's index.html for deep links and lost the immutable policy on its
fingerprinted files.

Inbound rules now match the folder-relative URL and set Cache-Control
directly for present and missing fingerprinted files, the fallback
rewrites to a relative index.html, and the only outbound cache rule
left applies no-cache to responses that have no policy yet.
@mikernet mikernet changed the title fix(wasm): Update IIS web.config for deep links fix(wasm): Rework IIS web.config for deep links, compression, caching and MIME types Sep 21, 2026
mikernet added a commit to Singulink/Singulink.UI that referenced this pull request Oct 10, 2026
…ching and MIME types

Matches the reworked template in unoplatform/uno.templates#2267, which also serves the app correctly from a site subfolder.
@mergify

mergify Bot commented Nov 10, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

This branch has not been deployed

No deployments
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.

WebAssembly web.config: deep links 404 on IIS and pre-compressed files are not served WASM Deep Linking on IIS Not Working with Default web.config

1 participant