Publish a .NET application to a Windows Server instance

in Amazon Lightsail

Amazon Lightsail is the easiest way to get started with AWS. lt includes everything you need to launch your project quickly for a low, predictable price.

This tutorial shows you how to publish a .NET application on a Windows Server 2016 instance in Amazon Lightsail. It includes steps to install the required server roles and features, configure Visual Studio 2019 community edition to connect to your instance, and publish the MVC ASP.NET web application template to your instance.

Get started with Lightsail for free. 

About this Tutorial
Time 60 minutes                                      
Cost Costs may apply
Use Case Compute
Products Amazon Lightsail
Audience Developer
Level Beginner - Intermediate 
Last Updated March 20, 2020

1. Create an Amazon Lightsail Account

This tutorial is free tier eligible with Amazon Lightsail, but costs may apply. 

Already have an account? Sign-in

2. Create a Windows Server 2016 instance in Amazon Lightsail

This tutorial requires that you create a Windows Server 2016 instance in Lightsail. To do so, follow the steps in the Launch a Windows Virtual Machine with Amazon Lightsail tutorial.

3. Install the required roles and features on your instance

You can connect to your Windows Server 2016 instance using the browser-based RDP client in the Lightsail console. After you’re connected, you can install the required server roles and features that will allow you to connect to your instance through Visual Studio and run .NET applications.


a. On the Instances tab of the Lightsail home page, choose the RDP quick-connect icon for your Windows Server 2016 instance.


b. After the browser-based RDP client window opens, choose the Windows icon and open Server Manager

net1

c. Choose Local Server in the left navigation menu, then choose On next to IE Enhanced Security Configuration (choosing On turns it Off).

Turning off IE Enhanced Security Configuration will allow you to download Microsoft Web Platform Installer later in this tutorial.

net2

d. In the configuration prompt, choose to turn off the feature only for administrators, and then choose OK.

net3

e. In Server Manager, choose Dashboard in the left navigation menu, then choose Add roles and features.

net4

f. Choose Next in the Add Roles and Features Wizard.

net5

g. Choose Role-based or feature-based installation in the Select installation type screen, and choose Next.

net6

h. Choose Next in the Select destination server screen.

net7

i. Choose Web Server (IIS) in the Select server roles screen. Choose Add features when you are asked if you would like to add the required features. Choose Next.

net8

j. Choose the features highlighted in this screenshot in the Select features screen, and then choose Next.

net10

k. Choose Next in the Web Server Role (IIS) screen.

net11

l. Choose the role services highlighted in this screenshot under the Web Server service.

net12

m. Choose the role services highlighted in this screenshot under the Performance and Security services.

net13

n. Choose the role services highlighted in this screenshot under the FTP Server and Management Tools services.

net14

o. Choose the role services highlighted in this screenshot under the Application Development service.

net15

p. Choose Next after you confirm that you selected all of the correct role services highlighted in the previous steps


q. Choose Restart the destination server automatically if required, and then choose Install in the Confirm installation selections screen.

The roles and features will require a few minutes to download and install. While that is completing, continue to the next section to install the Microsoft Web Platform Installer.

net16

4. Install Web Deploy on your instance

You must install the Web Deploy 3.6 extension on your Windows Server 2016 instance to enable deployment of web applications and web sites to your server. You install the extension using the Microsoft Web Platform Installer.


a. On your Windows Server 2016 instance, open Internet Explorer and browse to the following address:

http://www.microsoft.com/web/downloads/platform.aspx


b. Choose Install this extension, then choose Run to start the installer.

net17

c. Accept the terms in the license agreement, and choose Install in the Microsoft Web Platform Installer 5.1 Setup screen. Choose Finish to close the installer when the installation is complete.

net18

d. Choose the Start menu, then choose Microsoft Web Platform Installer.

net19

e. Search for Web Deploy 3.6, and choose Add next to that option in the search results.

net20

f. Choose Install to start the installation.

net21

g. At the prompt, choose I Accept to start the installation. Choose Finish to close the installer when the installation is complete.

net22

5. Create an ASP.NET MVC application in Visual Studio 2019

In these steps, you will create an application using the ASP.NET MVC template in Visual Studio 2019 community edition. To download and install Visual Studio 2019 community edition, see the Visual Studio website.


a. Open Visual Studio 2019 community edition on your local computer (not the Windows Server 2019 instance).

addednet1

b. Choose Create a new project.

net23

c. Choose C# in the language drop-down menu, and choose Web in the project types drop-down menu. Choose ASP.Net Web Application (.NET Framework) in the list of available projects, and choose Next.

net24

d. Choose .NET Framework 4.6 in the Framework drop-down menu, and choose Create.

net25

e. Choose MVC, and choose Create.

After this step, you will have a Model View Controller (MVC) website project template that you can edit in Visual Studio. When you are done editing your project, continue to the next section to publish your project to your Windows Server 2016 instance.

net26

6. Publish your .NET application to your Windows Server 2016 instance

In these steps, you will configure Visual Studio to connect to your Windows Server 2016 instance so that you can publish your .NET project to your server.


a. With your MVC project open in Visual Studio 2019 community edition, choose Build, and choose Publish WebApplication1.

If you renamned your project, then WebApplication1 is replaced with the name of your project.  

net27

b. Choose IIS, FTP, etc, and choose Create Profile in the Pick a publish target screen.

net28

c. Enter the following information in the Publish screen:

  • Choose Web Deploy in the Publish method drop-down menu.
  • Enter http://PublicIpAddress in the Site name text box. Replace PublicIpAddress with the public IP address of your Windows Server 2016 instance.  
    • You can get the public IP address of your instance in the Lightsail console.
  • Enter Default Web Site in the Site name text box.
    • This is name of the default website automatically configured when you installed Internet Information Services (IIS) on your Windows Server 2016 instance.
  • Enter Administrator in the User name text box. This is the default administrator user name for your Windows Server 2016 instance.
  • Enter the administrator password in the Password text box.
    • You can get the administrator password by going to the instance’s management page in the Lightsail console, and choosing Show default password under the Connect tab.
  • Enter http://PublicIpAddress in the Destination URL text box. Replace PublicIpAddress with the public IP address of your Windows Server 2016 instance.
    • You can get the public IP address of your instance in the Lightsail console.
addnet2
net30

d. Choose Validation Connection to test the connection.

A checkmark icon will appear if the validation is successful. If the validation is unsuccessful, confirm that you entered the correct information into the form (confirm the administrator password, and the IP address).

e. Choose Next.

addnet3

f. Ensure that Release is selected in the Configuration drop-down menu. Choose all options available under File Publish Options, and choose Save.

net33

g. Choose Publish in Visual Studio when you are ready to publish your project to your server.

net34

h. The Output in Visual Studio will show a successful message if your project was successfully published to your server.

addnet4

i. Browse to the public IP address of your Windows Server 2016 instance to confirm that the project was successfully published.

Your project was successfully published if you see a page similar to the following screenshot.

net36

Congratulations

You have published a .NET application to your Windows Server 2016 instance in Amazon Lightsail.

Amazon Lightsail is a great choice to develop, build, and deploy a variety of applications like content management systems, websites, and other platforms.

Was this tutorial helpful?

Thank you
Please let us know what you liked.
Sorry to disappoint you
Is something out-of-date, confusing or inaccurate? Please help us improve this tutorial by providing feedback.