In this tutorial, we'll explore the
process of hosting an asp.net core application on a Windows server using IIS,
Internet Information Services. These steps can be applied to host various types of
asp.net core applications, such as web API, MVC and blazor. For the purpose of this
demonstration, I'll be using a Blazor project. Our previous video delved into the asp.net
core hosting on a Linux Server. For additional details, you can locate the Video URL in the
description below. So let's proceed with the tutorial. Firstly, let's observe the application in
action by running it. Upon visiting the homepage, you'll find a simple welcome message. Navigating
to the counter page, you'll find a button that increments a displayed value with each click.
Moving on to the weather page, a table will be populated with dummy weather data. Now,
let's proceed to host this application on a Windows Server. I have already acquired a Windows
Server without IIS or any associated libraries installed. Our first step is to install IIS.
To accomplish this, let's open server manager which can be easily located by searching for it
in the start menu. Once the server manager has fully loaded, proceed by selecting the add roles
and features option located in the manage menu. This action will launch a wizard. Click on
next to advance to the installation type where you should opt for role based or feature-based
installation. In the subsequent step, the wizard will prompt you to select the server. Since we
are installing it on the current server, click next. Now it's time to choose the server role.
Enable the Web Server (IIS) option and the Wizard will automatically include the necessary
features. Continue with the default selection of Role services and proceed by clicking next. Feel free
to customize the Role Services if necessary, however I'll be continuing with the default settings.
Finally initiate the installation process by clicking the install button. Please note that I'm
skipping the installation portion of the video as it may take some time. After the installation
is complete, close the wizard. Now let's search for IIS in the start menu. Let me open it. Moving
forward, let's proceed with the installation of dotnet run time. To acquire the necessary setup files,
visit the official Microsoft website. Upon reaching the download page you may notice an option for
downloading the dotnet SDK. Since we are hosting the application on the server, only the runtime
is required. Select this option to explore the available download choices. On this page you'll
find the download options for the asp.net core runtime. Considering the installation on
a 64-bit Windows Server, let's opt for the x64 option. Typically the download will commence
automatically. In case it doesn't, you can initiate the download manually by clicking on the provided
link. Having successfully downloaded the runtime, let's navigate back. Additionally, to host the
application in IIS, we need to install the hosting bundle. Let's proceed by downloading that as well.
Let's proceed with the installation step by step. Begin by installing the runtime. Once the runtime
installation is complete, moving on to installing the hosting bundle. With these installations, we
have successfully set up the required services and libraries for hosting. Before proceeding with
publishing a project and hosting, it's essential to ensure that your domain name is correctly pointed
to the Server IP. This can be configured in the DNS settings of your domain. We'll be configuring
this URL for our project. Now let's initiate the project publishing process. Choose the target
as folder and if necessary adjust the publish location. In this case, I'm using the same location.
Proceed with the publishing process. Additionally, you have the option to modify the target runtime.
Given that we are deploying on a 64-bit Windows, select x64. Let's proceed with the publishing
once again. Now that we have the files, let's copy them to the server. To simplify the copying
process, I'll compress the files into a zip file. I'll paste the compressed file into the wwwroot
folder, which is the default folder for IIS. All the files have been organized within a folder
named demoapp. With in IIS, let's proceed with the necessary configuration. Begin by creating an
application pool for our application. Choose "No Managed Code" for the .Net CLR version and I'm
assigning the name as demoapp. Moving forward, let's add a new site in IIS. Specify the site name
and select the previously created application pool. Provide the physical path pointing to the folder
where we copied the files. Then specify the host name which in this case is the configured
demoapp.codingdroplets.com for our example. With the configurations completed. let's test the URL. Upon
refreshing the page, you can observe that the web page has loaded successfully. The functionality
to increment the count on button click and the demonstration of weather page are both operational.
The hosting process is now successfully set up and functional. So that's it for this video. Thank You
for joining us in this tutorial. We have covered the step-by-step process for hosting an ASP.Net
core application in Windows Server. Don't forget to like, share and subscribe for more content.
Stay tuned for more tutorials and Happy Coding!