All IT Courses 50% Off
Dotnet Tutorials

How to Host a Website on IIS?

IIS server (Internet Information Services server) is a Windows Server-based web application used to deliver website content over the internet to an end-user. IIS uses .NET web application frameworks such as ASP.NET MVC and Entity Framework; additionally, it also integrates with Visual Studio, all of which make it a popular choice for enterprises.

Other key features of IIS are its user’s ability to delegate control of the administration of the web site or web applications. It is great for the creation of access controls to different departments. For instance, your Web Developers may only need access to the front end of the Website, and your IT Technical teams only need access to the backend. IIS can easily integrate with API technology. IIS also scales very well; web site load balancing is a core feature and dynamic caching and compression.

How to Download and Install IIS?

Step 1: Download Windows Server from the URL https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2019 and try it for 180 days.

Step 2: Open Server Manager and click on Add roles and features.

Server Manager Add Roles And Features Windows Server 2019

Step 3: On the window, Before you begin, click on the Next button.

All IT Courses 50% Off
Windows Server Manager 2019 Before you begin

Step 4: On the Select installation type window, select Role-based or feature-based installation, and click on the Next.

Select Installation Type Windows Server 2019

Step 5: As we are installing to our local machine, choose Select a server from the server pool having the current machine selected and click on the Next. Also, you can select another server that you are managing from here.

Select Destination Server Windows Server 2019

Step 6: From the window, Select server roles, check the box next to Web Server (IIS). It will open up a new window, advising that additional features are required. Click on the Add Features button to install these as well and then click Next back on the Select server roles menu once it is complete. 

Server Manager Select Server Roles
Add IIS Features

Step 7: We will not be installing any additional features at this stage, so click Next on the window Select features.

Select Features to Install

Step 8: Click Next on the Web Server Role (IIS) window after reading the information.

Install Web Server Role - Windows Server 2019

Step 9: At this point on the Select role services window, you can also install additional services for IIS if required. You don’t need to concern about this now as you can always come back and add more later, so click Next for now to install the defaults.

Select Role Services - Windows Server 2019

Step 10: Finally, on the Confirm installation selections window, review the items that are to be installed and click Install when you are ready to proceed with installing the IIS web server.

Confirm Installation Selections - Windows Server 2019

Step 11: Once the installation is finished, click the close button. At this point, IIS should be by default running on port 80 with the firewall rule World Wide Web Services (HTTP Traffic-In) as enabled in the Windows firewall automatically.

IIS Installation Progress - Windows Server 2019

Step 12: You can perform a simple test by opening up a web browser and browsing to the server that you have installed IIS on. You should see the default IIS page.

Windows Server 2019 IIS default web page

How to Deploy a Website in IIS?

After developing the web application, the next step is to deploy the web application. It needs to be deployed so that other users can access it. The deployment is done on an IIS Web server and there are two ways to deploy an application to the server:

  • Using the File Copy method.
  • Using the Web publish method.

Using the File Copy method:

Step 1: Let us first ensure we have our web application DemoApplication open in Visual Studio.

Deploying a website on IIS

Step 2: Open the Demo.aspx file and enter the string “I am ASP.Net.”

<!DOCTYPE html>
<html xmlns="https://www.w3.ore/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
  <form id="form1" runat="server”>
         <div>
          ASP.Net
         </div>
  </form>
</body>
</html>

Now run the application in Visual Studio to make sure it works.

Using the Web publish method:

Another method to deploy web applications is via publishing a website. The main difference in this method is that

  • You will have more control over the deployment.
  • You can also specify to which Web site you want to deploy your application.
  • For example, if you have two websites WebSite1 and WebSite2. If you use the Web publish method, then you can publish your application to any website. Also, you do not need to know the physical path of the Web site.
  • In the FileCopy method, you need to know the physical path of the website.

Step 1: In this step, right-click the web project in the Solution Explorer and choose the option Publish from the context menu.

Image for post

Step 2: In the next screen, select the New Profile option to create a new Publish profile. It will contain the settings for publishing the web application using Web Deploy.

Image for post

Step 3: In the next screen, provide the details of the profile. Give a name for the profile and click the OK button to create the profile.

Step 4: In the next screen, give all the publishing process details. Choose the Publish method as Web Deploy. Select the Service URL as Localhost. Enter the site name as the Default Website – Note that this is the name of the IIS website. Enter the destination URL as http://localhost.

Finally, click the Next button to proceed.

Image for post

Click on the Validate Connection button at the bottom of the Connection section. You should get a green right mark. If you enter the incorrect site name, then it will give an error as below:

Web Deployment task failed. (Site ‘localhost’ does not exist Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SITE_DOES_NOT_EXIST).

Image for post

Step 5: Click on the Next button on the following screen to continue.

Image for post

Step 6: Finally, click on the Publish button to publish the Website.

Image for post

When all the above steps are executed, the following output is visible in Visual Studio.

Output:

Deploying a website on IIS

From the above output, you can now see that the Publish has succeeded.

Now open the browser and navigate to the URL: http://localhost/Demo.aspx

How to Host a Website on IIS?

You can see from the above shown output that when you browse to http://localhost/Demo.aspx, the following page appears. It also displays the text ASP.Net.

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles

Back to top button