2

I'm trying to get a Blazor WASM app deployed on IIS, following the instructions here.

  • This is just the out of the box sample Blazor WASM app
  • I've published the app to a folder
  • I've added the URL rewriting module to IIS
  • I've added dynamic compression support to IIS
  • I created a new web app in the default website and pointed it to the folder where I published the Blazor app

Invoking the app produces a page containing "An unhandled error has occurred. Reload".

Looking at the requests in the browser dev tools, index.html is being fecthed from the wwwroot folder, suggesting that the url rewrite rule is firing, but the requests for css/bootstrap.min.css, _framework/blazor.webassembly.js and css/app.css all fail with status 404 - Not Found.

What am I missing?

Windows 10 2004.

1 Answer 1

2

try to set the base path in your index.html file:

<base href="/CoolApp/"> 

below is the iis application folder path:

enter image description here

you can set it to your publish folder.

web.conifg file:

<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <staticContent> <remove fileExtension=".dat" /> <remove fileExtension=".dll" /> <remove fileExtension=".json" /> <remove fileExtension=".wasm" /> <remove fileExtension=".woff" /> <remove fileExtension=".woff2" /> <mimeMap fileExtension=".dll" mimeType="application/octet-stream" /> <mimeMap fileExtension=".dat" mimeType="application/octet-stream" /> <mimeMap fileExtension=".json" mimeType="application/json" /> <mimeMap fileExtension=".wasm" mimeType="application/wasm" /> <mimeMap fileExtension=".woff" mimeType="application/font-woff" /> <mimeMap fileExtension=".woff2" mimeType="application/font-woff" /> </staticContent> <httpCompression> <dynamicTypes> <add mimeType="application/octet-stream" enabled="true" /> <add mimeType="application/wasm" enabled="true" /> </dynamicTypes> </httpCompression> <rewrite> <rules> <rule name="Serve subdir"> <match url=".*" /> <action type="Rewrite" url="wwwroot\{R:0}" /> </rule> <rule name="SPA fallback routing" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="wwwroot\" /> </rule> </rules> </rewrite> </system.webServer> </configuration> 

index file:

enter image description here

output:

enter image description here

Note: make sure you assign the iis_iusrs and iusr permission to the site folder.

https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/?view=aspnetcore-3.1&tabs=visual-studio

Sign up to request clarification or add additional context in comments.

1 Comment

Adding the app path to the <base> tag did the trick - thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.