Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Skip to main content
TUTORIAL

Publish a .NET Application to a Windows Server 2022 Instance in Amazon Lightsail

Introduction

Overview

Amazon Lightsail is one of the easiest ways 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 2022 instance in Amazon Lightsail.

Get started with Lightsail for free

What you will accomplish

In this tutorial, you will:

  • install the required server roles and features

  • configure Visual Studio 2022 Community edition to connect to your instance

  • publish the ASP.NET core web application template to your instance

Prerequisites

Before starting this tutorial, you will need:

Implementation

Beginner

60 minutes

Free Tier eligible

April 28, 2023

Create an Amazon Lightsail account

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

Sign up for AWS

Already have an account? Sign in

Create a Windows Server 2022 instance in Amazon Lightsail

This tutorial requires that you create a Windows Server 2022 instance in Lightsail. To do so, follow the steps in the Launch a Windows Virtual Machine with Amazon Lightsail tutorial, but make sure to select Windows Server 2022 when choosing the operating system-only instance image.

Install the required roles and features on your instance

You can connect to your Windows Server 2022 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.

1. Connect to your instance

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

2. Open Server Manager

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

3. Turn off IE Enhanced Security Configuration

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

Note: Turning off IE Enhanced Security Configuration will allow you to download resources later in this tutorial.

Missing alt text value

4. Turn IE Enhanced Security Configuration off for administrators

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

Missing alt text value

5. Add roles and features

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

"Server Manager dashboard interface showing options to configure a local server, add roles and features, and manage server groups."

6. Continue through the wizard

Choose Next in the Add Roles and Features Wizard.

Missing alt text value

7. Choose an installation type

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

"Windows Server Add Roles and Features Wizard displaying the 'Select installation type' step with options for role-based or feature-based installation and remote desktop services installation."

8. Select a destination server

Choose Next in the Select destination server screen.

"Add Roles and Features Wizard showing server selection with one server listed, running Microsoft Windows Server 2022 Datacenter."

9. Select a server role

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.

"Windows Server Add Roles and Features Wizard showing 'Web Server (IIS)' selected under server roles with a description on the right."

10. Select features

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

Screenshot of the "Add Roles and Features Wizard" in Windows Server, showing .NET Framework 4.8 features selected, including ASP.NET 4.8 and WCF Services.

11. Review the information about web server roles

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

Alt-text: Screenshot of the Add Roles and Features Wizard in Windows Server, showing the Web Server Role (IIS) description and options to proceed with installation.

12. Select web server services

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

Screenshot of the "Add Roles and Features Wizard" in Windows Server, showing selected role services for Web Server (IIS), including "WebDAV Publishing" highlighted.

13. Select performance and security services

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

Missing alt text value

14. Select FTP server and management tools services

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

Missing alt text value

15. Select application development services

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

Missing alt text value

16. Confirm selections

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

17. Restart the destination server

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.

Alt-text: "Windows Server Add Roles and Features Wizard showing confirmation of selected features, including .NET Framework 4.8 and Web Server (IIS), with the Install button highlighted."

Install Web Deploy on your instance

You must install the Web Deploy 4.0 extension on your Windows Server 2022 instance to enable deployment of web applications and websites to your server.

1. Download Web Deploy

On your Windows Server 2022 instance, open Internet Explorer and download Web Deploy 4.0.

2. Open the file

After the download completes, choose Open file to start the installer.

Missing alt text value

3. Start installation

Choose Next on the initial Setup Wizard screen.

"Microsoft Web Deploy 4.0 Setup Wizard screen with options to proceed or cancel installation."

4. Accept terms

Accept the terms in the license agreement, and choose Next in the Microsoft Web Deploy 4.0 Setup screen.

Missing alt text value

5. Choose a setup type

Choose Complete on the Choose Setup Type screen.

"Microsoft Web Deploy 4.0 Setup window showing setup type options: Typical, Custom, and Complete, with 'Complete' selected."

6. Install Web Deploy

Choose Install to start the installation, then choose Finish to close the installer when the installation is complete.

Missing alt text value

Install ASP.NET Core 6.0 Hosting Bundle

Because we’re going to publish an ASP.NET Core Web App to the Windows Server 2022 instance, you need to install the ASP.NET Core 6.0 Hosting Bundle.

1. Download Hosting Bundle

On your Windows Server 2022 instance, open Internet Explorer and download ASP.NET Core 6.0 Hosting Bundle.

Missing alt text value

2. Open the file

After the download completes, choose Open file.

"Browser downloads panel showing a file named 'dotnet-hosting-6.0.15-win.exe' with a cursor hovering over the 'Open file' option."

3. Accept the terms

Accept the terms in the license agreement, and choose Install in the Windows Server Hosting Setup screen.

Missing alt text value

4. Verify installation

After the installation completes, choose Close.

Missing alt text value

Create an ASP.NET Core Web Application in Visual Studio 2022

In these steps, you will create an application using the ASP.NET Core Web App template in Visual Studio 2022 Community edition. To download and install Visual Studio 2022 Community edition, see the Visual Studio website.

1. Open Visual Studio

Open Visual Studio 2022 Community edition on your local computer (not the Windows Server 2022 instance).

2. Create a project

Choose Create a new project.

Missing alt text value

3. Configure project

Choose C# in the language dropdown menu. Choose ASP.NET Core Web App in the list of available projects, and choose Next.

Missing alt text value

3. Configure project

Choose a Project name, and choose Next.

Missing alt text value

4. Create the project

On the Additional information screen, make sure the Framework selected is .NET 6.0, and choose Create.

After this step, you will have an ASP.NET core 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 2022 instance.

Missing alt text value

Publish your .NET application to your Windows Server 2022 instance

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

1. Add a firewall rule

For publishing to work from a remote network, you need to add a firewall rule to your Windows Server 2022 instance. Open your Lightsail console and open the Networking tab of your instance. Choose + Add rule and enter 8172 as the port, then choose Create.

Missing alt text value

3. Choose a publishing target

Choose Web Server (IIS) and choose Next in the Publish screen.

Missing alt text value

4. Choose Web Deploy

Select Web Deploy and choose Next.

Missing alt text value

5. Get the public IP

Get the public IP address of your Windows Server 2022 instance from the Lightsail console.

Missing alt text value

5. Get the public DNS name

Perform a reverse DNS lookup by running nslookup PublicIpAddress in PowerShell to get the public DNS name for your Windows Server 2022 instance’s IP address; this PublicHostname will be used in the next step as the server name.

Windows PowerShell window displaying server and address details, with the hostname "ec2-44-201-34-227.compute-1.amazonaws.com" highlighted in red.

6. Configure web server connection

On the next screen, enter the following information:

Enter PublicHostname in the Server text box. Replace PublicHostname with the public DNS name of your Windows Server 2022 instance retrieved in the previous step.

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 2022 instance.

Enter http://PublicHostname in the Destination URL text box. Replace PublicHostname with the public DNS name of your Windows Server 2022 instance retrieved in the previous step.

Missing alt text value

7. Enter credentials

Enter Administrator in the User name text box. This is the default administrator user name for your Windows Server 2022 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 Retrieve default password under the Connect tab.

"Screen displaying a default password for an instance with a button labeled 'Okay, got it!'"

8. Validate the connection

Choose Validate Connection to test the connection. You might get a certificate error like the one in the screenshot when connecting the first time. This is because the server uses a default certificate and you can safely accept it if the hostname displayed matches the one you intended to connect to.

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).

Missing alt text value

9. Monitor profile creation

Choose Finish, then choose Close when the Publish profile creation progress completes successfully.

Missing alt text value

10. Publish your project

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

Missing alt text value

11. Check the output

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

Missing alt text value

11. Check the output

Browse to the PublicHostname of your Windows Server 2022 instance to confirm that the project was successfully published.

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

Missing alt text value

Clean up resources

In the following steps, you clean up the resources you created in this tutorial. It is a best practice to delete instances and resources that you are no longer using so that you are not continually charged for them.

1. Delete the instance

On the Instances tab of the Lightsail home page, choose the ellipsis (⋮) icon next to the Windows Server instance you just created and choose Delete.

Missing alt text value

2. Confirm deletion

Choose Yes, delete from the prompt.

Missing alt text value

Conclusion

Congratulations! You have published a .NET core web application to your Windows Server 2022 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.