2 Ways to Deploy Website in IIS

Source: https://www.guru99.com/deploying-website-iis.html

How to Deploy Website in IIS via File copy

After developing a web application, the next important step is to deploy the web application. The web application needs to be deployed so that it can be accessed by other users. The deployment is done to an IIS Web server.

There are various ways to deploy a web application. Let’s look at the first method which is the File copy.

We use the web application created in the earlier sections. Let’s follow the below-mentioned steps to achieve this.

Step 1) Let’s 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 “Guru 99 ASP.Net.”

Deploying a website on IIS

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

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

Output:-

Deploying a website on IIS

The text ‘Guru 99 ASP.Net’ is displayed. You should get the above output in the browser.

Step 3) Now it’s time to publish the solution.

  1. Right-click the ‘DemoApplication’ in the Solution Explorer
  2. Choose the ‘Publish’ Option from the context menu.

Deploying a website on IIS

It will open another screen (see step below).

Step 4) In the next step, choose the ‘New Profile’ to create a new Publish profile. The publish profile will have the settings for publishing the web application via File copy.

Deploying a website on IIS

Step 5) In the next screen we have to provide the details of the profile.

  1. Give a name for the profile such as FileCopy
  2. Click the OK button to create the profile

Deploying a website on IIS

Step 6) In this step, we specifically mention that we are going to Publish website via File copy.

  1. Choose the Publish method as File System.
  2. Enter the target location as C:\inetpub\wwwroot – This is the standard file location for the Default Web site in IIS.
  3. Click ‘Next’ button to proceed.

Deploying a website on IIS

Step 7) In the next screen, click the Next button to proceed.

Deploying a website on IIS

Step 8) Click the ‘Publish’ button in the final screen

Deploying a website on IIS

When all of the above steps are executed, you will get the following output in Visual Studio

Output:-

Deploying a website on IIS

From the output, you will see that the Publish succeeded.

Now just open the browser and go to the URL – http://localhost/Demo.aspx

Deploying a website on IIS

You can see from the output that now when you browse to http://localhost/Demo.aspx , the page appears. It also displays the text ‘Guru 99 ASP.Net’.

How to Publish ASP.NET Website

Another method to deploy the web application is via publishing a website. The key difference in this method is that

  • You have more control over the deployment.
  • You can specify to which Web site you want to deploy your application to.
  • For example, suppose if you had two websites WebSiteA and WebSiteB. If you use the Web publish method, you can publish your application to any website. Also, you don’t need to know the physical path of the Web site.
  • In the FileCopy method, you have to know the physical path of the website.

Let’s use the same Demo Application and see how we can publish using the “website publish method.”

Step 1) In this step,

  1. Right-click the ‘DemoApplication’ in the Solution Explorer
  2. Choose the Publish Option from the context menu.

Deploying a website on IIS

Step 2) On the next screen, select the ‘New Profile’ option to create a new Publish profile. The publish profile will have the settings for publishing the web application via Web Deploy.

Deploying a website on IIS

Step 3) In the next screen we have to provide the details of the profile.

  1. Give a name for the profile such as ‘WebPublish’
  2. Click the ‘OK’ button to create the profile

Deploying a website on IIS

Step 4) In the next screen, you need to give all the details for the publish process

  1. Choose the Publish method as Web Deploy
  2. Select the server as Localhost
  3. Enter the site name as Default Website – Remember that this is the name of the website in IIS
  4. Enter the destination URL as http://localhost
  5. Finally, click the Next button to proceed

Deploying a website on IIS

Step 5) Click the ‘Next’ button on the following screen to continue

Deploying a website on IIS

Step 6) Finally, click the Publish button to publish the Website

Deploying a website on IIS

When all of the above steps are executed, you will get the following output in Visual Studio.

Output:-

Deploying a website on IIS

From the output, you will see that the Publish succeeded.

Now just open the browser and go to the URL – http://localhost/Demo.aspx

Deploying a website on IIS

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

Summary

  • After an ASP.Net application is developed, the next step is that it needs to be deployed.
  • In .Net, IIS is the default web server for ASP.Net applications.
  • ASP.Net web applications can be deployed using File copy method.
  • ASP.Net web applications can also be deployed using Web Publish method.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s