question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot host Blazor WebAssembly App via IIS

See original GitHub issue

Describe the bug

Cannot host into my IIS Blazor WebAssembly App project.

I created a new Blazor project using Visual Studio 2019 (look at the picture)

I checked https, ASP.NET Core hosted and Progressive Web Application

Default blazor webassembly app project

After that visual studio creates the client project,the server project and a shared class project. I make sure that the project has no error so I compile it and run it on visual studio.

After that I want to host it into my IIS , so i go into the server project , right click , publish and I publish everything into my release folder.

Everything goes fine, now I go into my IIS , add new site, and select the path of the publish folder generated before (I used the port 80 for this test).

I also grant to the web config the IIS_IUSRS permission.

Now I type localhost:80 into my browser and I go into an infinite loop of waiting for the page that loads , but it never loads.

No errors are shown into the browser.

So I went into my IIS manager and say that the web config generated by default by visual studio is seen as wrong.

My webconfig.xml :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\Funzia.Server.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 4872489F-5CAD-4DF4-BAFC-9D401F53BF48-->

I have installed ASP.NET core Runtime bundle also dotnet-hosting-2.2.2.

In fact I can easily host a Server App blazor , zero problems, but when I try to publish an Blazor WebAssembly App it is not working.

Other useful info:

The modules are not missing.

enter image description here

I also tried to add an autosigned certificate and tried to access by https but I’ve experienced the same result as going with http.

More further I also tried to publish the project via console , I thought that maybe visual studio could create corrupted web config file, but the file created was the same.

I’ve found that also some other users are experiencing this problem but I have not found any solution yet.

I even tried to follow this video : https://www.youtube.com/watch?v=k2qAuwNpM_s , but for me the same things that he does are not working, as my browser will keep loading for an infinite amount of time my webapp.

Any suggestions?

To Reproduce

Exceptions (if any)

Further technical details

  • ASP.NET Core version 3.1
  • Include the output of dotnet --info: .NET Core SDK (che rispecchia un qualsiasi file global.json): Version: 3.1.301 Commit: 7feb845744

Ambiente di runtime: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.301\

Host (useful for support): Version: 3.1.5 Commit: 65cd789777

.NET Core SDKs installed: 3.1.300 [C:\Program Files\dotnet\sdk] 3.1.301 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and it’s version: Visual studio 2019, version 16.6.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tn-5commented, Aug 12, 2020

That comment was based on supplying the required web.config manually.

The standard web config that should be generated when publishing a standalone wasm application to IIS is as follows:

<?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>

You can put this in your wwwroot folder and it will be published to IIS. However, the publish process will still add the incorrect aspnet handler lines. If you manually delete those after publish it should work. However, this would need to be done every time you publish, so it is not really a solution

0reactions
danroth27commented, Aug 18, 2020

Duplicate of #24568

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to host Blazor application - iis
Unable to host Blazor application · Click on publish app · Select Folder, note it's going to ... · Open IIS, navigate to...
Read more >
Host and deploy ASP.NET Core Blazor WebAssembly
Learn how to host and deploy Blazor WebAssembly using ASP.NET Core, Content Delivery Networks (CDN), file servers, and GitHub Pages.
Read more >
Hosting A Blazor Visual Studio Project Directly In IIS
You Need A Web.config File To Host A Blazor App In IIS. Blazor projects, by default, do not contain web.config files. However, IIS...
Read more >
How do I deploy a Blazor application in IIS?
The Blazor application can be deployed to IIS using Visual Studio or you can also configure manually. Find the steps to deploy the...
Read more >
Blazor WebAssembly : Deploy to IIS(Internet Information System)
Hey Coders, In this tutorial, I am showing how you can deploy your Blazor WebAssembly application on IIS. First we are going to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found