How do i publish a Blazor ASP.NET App in IIS?

Viewed 17854

i have build a Blazor-Server-App (ASP.NET Core hosted) and published it from Visual Studio to a local folder. It worked fine.

Now i want to publish it on my windows server. It successfully runs some ASP.NET web APIs, so basically its working. It has an own domain.

What i did now is copying the local folder to the server and opening IIS Manager. I added a website and set the path to the folder.

But now, when i click on "Application Setting" i get an error regarding the web.config, see Screenshot.

I would appreciate any hints on why the web.config Visual Studio created does not work with my IIS.

Regards, Tim

enter image description here

2 Answers

to publish blazor app in iis first make sure you installed below iis feature:

enter image description here

  • .NET Core hosting bundle
  • ASP.NET Core Runtime

Download and Install the Runtime and Hosting bundle as per your version.

https://dotnet.microsoft.com/download/dotnet-core/3.1

after installing hosting bundles do not forget to restart the machine. if you installed a hosting bundle bore installing iis you need to repair it.

now Open blazor application in Visual Studio, right-click on a project from solution explorer and select “Publish..” option.

enter image description here

Click on Publish > Start > Folder > choose a folder path and click on the “Create Profile” button.

enter image description here

Click on the “Publish” button.

enter image description here

Now, Open IIS.

Right Click on “SItes” > “Add Website…”.

Set all details like “Site Name”, “Physical path”, “IP address” etc, and click on the “OK” button.

enter image description here

Done!, now right-click on Browse and you can see your hosted application inside the browser.

enter image description here

You can find all the info for blazor hosting here: https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-3.1

There is a section on the 500 error you're getting: If a 500 - Internal Server Error is received and IIS Manager throws errors when attempting to access the website's configuration, confirm that the URL Rewrite Module is installed. When the module isn't installed, the web.config file can't be parsed by IIS. This prevents the IIS Manager from loading the website's configuration and the website from serving Blazor's static files.

Related