Web UI on IIS¶
The UI (ui/src/MiddlewareForge.Web) is a Blazor Web App with Interactive Server rendering. It runs inside IIS through the ASP.NET Core Module (ANCM), in process. Browsers talk only to IIS; the Blazor server calls the backend over the internal network and adds the X-Forge-Api-Key header.
Prerequisites on the Windows Server¶
- IIS role services:
- Web Server (IIS)
- Application Development → WebSocket Protocol: required. Without it Blazor falls back to long polling and reconnects often.
- Security → Request Filtering (installed by default)
- The ASP.NET Core 10 Hosting Bundle (the .NET runtime and
AspNetCoreModuleV2). Install it after IIS; if IIS was added later, run the bundle's Repair. Then runnet stop was /yandnet start w3svc, or restart the server. -
Check that the IIS server reaches the backend:
Publish¶
On a build machine with the .NET 10 SDK:
- Copy
publish/webto the server, for exampleD:\MiddlewareForge\web. - Replace the generated
web.configwithdeploy/iis/web.configand edit the values markedEDIT(backend URL, keys folder). - For a self-contained publish (
-r win-x64 --self-contained), changeprocessPathas the comment in the file explains.
Application pool and site¶
- Create the application pool
MiddlewareForge:- .NET CLR version: No Managed Code; Managed pipeline: Integrated; Enable 32-Bit Applications: False
- Identity:
ApplicationPoolIdentity, or a dedicated low-privilege account - Load User Profile: True
- Start Mode: AlwaysRunning and Idle Time-out: 0. An idle shutdown drops every open session's live connection.
- Regular recycling: a fixed off-hours time instead of the 1740-minute default. A recycle disconnects open browsers; no work on the backend is lost.
- Create the site (or an application under an existing site) with physical path
D:\MiddlewareForge\weband the poolMiddlewareForge. - Add an HTTPS binding with the server certificate. Remove the plain HTTP binding or keep it for redirects only; the app redirects to HTTPS and sends HSTS in Production.
The API key¶
Do not put ForgeApi__ApiKey in web.config. Set it as an application-pool environment variable (IIS 10+), stored in applicationHost.config, which ordinary site administrators cannot read:
& "$env:windir\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/applicationPools `
/+"[name='MiddlewareForge'].environmentVariables.[name='ForgeApi__ApiKey',value='<same value as FORGE_API_KEY>']" `
/commit:apphost
Data Protection keys¶
Blazor circuits and antiforgery tokens are protected with Data Protection keys. Keep them in a folder so they survive recycles and deployments:
New-Item -ItemType Directory D:\MiddlewareForge\keys
icacls D:\MiddlewareForge\keys /inheritance:r /grant:r "IIS AppPool\MiddlewareForge:(OI)(CI)M" "Administrators:(OI)(CI)F"
Point DataProtection__KeysPath in web.config at that folder.
Folder permissions¶
The pool identity needs Read & execute on D:\MiddlewareForge\web, and Modify on D:\MiddlewareForge\keys and on D:\MiddlewareForge\web\logs (only while stdout logging is on).
Settings¶
| Setting (environment variable) | Where | Purpose |
|---|---|---|
ASPNETCORE_ENVIRONMENT |
web.config | Production enables HSTS and the generic error page |
ForgeApi__BaseUrl |
web.config | Internal backend URL, e.g. http://forge-backend.internal:8000 |
ForgeApi__ApiKey |
application pool | Equal to the backend's FORGE_API_KEY |
ForgeApi__MaxUploadBytes |
web.config (optional) | Per-file upload limit; at or below the backend's UPLOAD_MAX_BYTES |
DataProtection__KeysPath |
web.config | Persistent key folder |
Values in appsettings.json are defaults only; environment variables override them.
Web farm¶
A Blazor circuit lives in one server's memory, so:
- Session affinity: enable ARR Server Affinity (sticky sessions) in Application Request Routing, or the equivalent on your load balancer.
- Shared keys: all servers use the same
DataProtection__KeysPath, for example a UNC share every pool identity can modify. The application name is fixed inProgram.cs. - WebSockets: the load balancer must pass
Upgradethrough, with an idle timeout of at least a few minutes.
All servers use the same single backend.
Verify¶
https://<site>/healthzreturns{"status":"ok"}(the UI process only).- The home page's app-bar chip reads Backend ready.
- In the browser developer tools → Network → WS, the
_blazorconnection is a WebSocket with status 101. - Create a task and upload a document; the plan appears. This proves the backend URL and the API key.
IIS-specific errors (500.19, 500.30, 502.5, reconnect loops) are covered in Troubleshooting.