In this blog post, we will discuss how to publish a Blazor Server Application to IIS. Here are we going to create a Blazor Server application using the default Blazor Server template in Visual Studio 2019 and we will publish the same in the IIS server. If you are completely new to Blazor application, I would highly recommend you to check the introductory post.
Step to publish a Blazor Server application to IIS
- Enable the Internet Information Service (IIS) feature.
- Install ASP.NET Core Runtime Hosting Bundle.
- Create a Blazor Server Application in Visual Studio 2019.
- Publish the Application to a “Folder or File share” profile.
- Host the application in IIS.
- Browse the application.
Enable the Internet Information Service (IIS) feature
The first step is to have Internet Information Services (IIS Web Server) up and running so the application can be hosted in it. The step can be skipped if the IIS is already up and running else the following step needs to be performed.
1. Open Program and Features Dialog
- Press Windows Key + R and type appwiz.cpl and press OK to open the dialog.
2. Select “Turn Windows feature on or off”
3. Select Internet Information Service and enable the following
- Web Management Tools
- World Wide Web Services
Enabling the feature might require to restart the machine, so restart the machine.
Install ASP.NET Core Runtime Hosting Bundle
The second step is to install the ASP.NET Core Runtime Hosting Bundle. The Blazor Server is executed as an ASP.NET Core application on the server, so the runtime requirement is the same as an ASP.NET Core application.
The Runtime Hosting Bundle will install the IIS runtime support (ASP.NET Core Modules) so that we can host the Blazor Server application on the IIS. The installer can be found on the .NET Core download page here: and can be found under the “Run apps – Runtime” section of the page as shown in the snapshot.
Download and install the package. Completing this step will make the IIS ready to host the Blazor Server application.
Create a Blazor Server Application
The next step is to create a Blazor Server application, if you have an existing application then you can skip this step entirely. The application is created using the default Blazor Server project template and no code changes have been made to the application. The short video shows how to create a Blazor Server application in Visual Studio 2019.
Publish the Application using “Folder or File share” profile.
Now we have the application ready, so we will publish it. Steps to publish the application to a local folder:
- Right-click on the project name and select Publish.
- Select Folder from “Pick a publish target” and click on “Create Profile“
- Click Publish
- Make a note of the published location from the Output Window
The entire step is shown in the GIF below.
Host the application in IIS
At this point we have out published artifacts ready, the next step is to host these artifacts in IIS.
1. Copy the published folder to web root folder C:\inetpub\wwwroot\
2. Open IIS Manager
Press Windows + R, and type inetmgr and press OK.
2. Add Website
Right click on Sites and select Add Website
Provide the following details in Add Website dialog
- Site name: HelloBlazor [put your own name]
- Physical path: C:\inetpub\wwwroot\publish\
- Port: 8090 [put your own name]
- Click OK
Browse the application
Open the browser and put the URL: localhost:8090 (your given port number)
This concludes the post, I hope you find the post on how to publish a Blazor Server Application to IIS helpful. Thanks for visiting, Cheers!!!.