Reputation: 333
I'm trying to get a Blazor WASM app deployed on IIS, following the instructions here.
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.
Upvotes: 2
Views: 4080
Reputation: 12749
try to set the base path in your index.html file:
<base href="/CoolApp/">
below is the iis application folder path:
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:
output:
Note: make sure you assign the iis_iusrs and iusr permission to the site folder.
Upvotes: 2