9 Hosting And Deploying Asp Net Core Application

NET Centric Computing · Unit 9 · 2 hrs

Hosting and Deploying ASP.NET Core Application

Exam-focused notes for Hosting and Deploying ASP.NET Core Application (NET Centric Computing, CSC378): what the TU syllabus asks and how it has actually been tested, with 5 solved past questions from this unit.

Hosting and Deploying ASP.NET Core Application in short

This unit is about getting a finished ASP.NET Core application in front of users: the web servers and hosting models available, how the ASP.NET Core Module ties into IIS, packaging an application with Docker, and publishing to Azure.

Hosting and Deploying ASP.NET Core Application: notes

App Servers and Hosting models: IIS, Nginx, Apache, ASP.NET Core Module, Kestrel

Once an application has been built, it must be hosted, meaning deployed onto a server so that other people can reach it over the network. Several web servers can host an ASP.NET Core application. IIS comes from Microsoft and runs only on Windows; it ships as part of the operating system, integrates closely with .NET and other Microsoft services such as MS SQL Server, and is a comfortable choice for teams already working in the Windows ecosystem. Apache, maintained by the Apache Software Foundation, is open source, free of licensing fees, flexible, has a high level of security, and benefits from a large user community, running efficiently on most operating systems but especially popular paired with Linux. NGINX, originally developed by Igor Sysoev, is a free, open-source, lightweight web server that can also act as a mail proxy or a reverse proxy; it is known for handling large amounts of traffic with comparatively limited hardware.

What this unit covers

  • App Servers and Hosting models: IIS, Nginx, Apache, ASP.NET Core Module, Kestrel
  • Docker and Containerization
  • Publish to Azure cloud

App Servers and Hosting models

2081 · 5 marks

Describe the procedure of deploying .NET core application. [5]

Show solved answer

Deploying a .NET Core Application

Introduction

.NET Core is a cross-platform framework, and its Command-Line Interface (CLI) provides tools to build, run, test, and publish .NET Core applications. The .NET Core CLI is installed with the .NET Core SDK and does not need to be installed separately.


Step-by-Step Deployment Procedure

Step 1: Verify .NET Core CLI Installation

Before deploying, confirm that the CLI is properly installed by opening the command prompt and typing:

dotnet

If it displays usage information, the CLI is installed correctly.


Step 2: Create the Application

Create a new project directory and initialize the application using CLI commands:

mkdir myapp
cd myapp
dotnet new console

This creates the necessary project files:

  • Program.cs (main source file)
  • myapp.csproj (project configuration file)

Step 3: Restore Packages

Restore all required NuGet packages and dependencies:

dotnet restore

This ensures all dependencies defined in the .csproj file are downloaded and available.


Step 4: Build the Application

Compile the application to check for errors and generate the build output:

dotnet build

Note: When using .NET Core SDK, the application is built automatically when needed, so there is no need to worry about executing outdated code.


Step 5: Run the Application (Testing)

Test the application locally before deployment:

dotnet run

This compiles (if needed) and executes the application directly.


Step 6: Publish the Application

Publish the application to prepare it for deployment on a target server:

dotnet publish -c Release -o ./publish
  • -c Release specifies the Release configuration (optimized build)
  • -o ./publish specifies the output directory where published files are placed

This generates all necessary files (DLLs, configuration files, runtime files) in the output folder.


Step 7: Deploy to the Server

Copy the published output to the target server. For a web application, the deployment typically involves:

  • Placing the published files on the server
  • Configuring a reverse proxy (such as IIS, Nginx, or Apache)
  • The reverse proxy receives requests from the browser and passes them to the ASP.NET Core application, which runs a self-hosted web server (Kestrel)
Browser --> Reverse Proxy (IIS/Nginx) --> ASP.NET Core App (Kestrel)

Summary Table

StepCommandPurpose
Verify CLIdotnetCheck installation
Create Appdotnet new consoleInitialize project
Restoredotnet restoreDownload dependencies
Builddotnet buildCompile source code
Rundotnet runTest locally
Publishdotnet publishPrepare for deployment

Conclusion

The .NET Core CLI provides a simple and consistent cross-platform procedure for deploying applications. Higher-level IDEs like Visual Studio internally use the same CLI commands to restore, build, and publish .NET Core applications.

Open this answer on its own page →

2079 · 10 marks

Describe any two hosting models for core application. Design a client side validation application using jquery for taking input data from student in Library Management System, assume your own assumptions.[10]

--- ASP.NET Core supports multiple hosting models that define how the application is hosted and served. Two important hosting models are described below: --- In the In-Process hosting model, the ASP.NET Core application runs inside the IIS worker process (w3wp.exe for IIS or iisexpress.exe for II...

Open this answer on its own page →

2078 · 5 marks

Explain the process to deploy the core application. [5]

Deploying an ASP.NET Core application involves choosing an appropriate hosting model and web server to serve the application to end users. The .NET Core CLI also plays a key role in building and publishing the application before deployment. --- The .NET Core CLI is a cross-platform tool used to c...

Open this answer on its own page →

2076 · 5 marks

Differentiate between ASP and IIS.[5]

--- ASP is a server-side scripting technology developed by Microsoft that allows developers to create dynamic web pages and web applications. It processes scripts on the server before sending the result (HTML) to the client's browser. IIS is a web server software developed by Microsoft that hosts...

Open this answer on its own page →

2076 · 5 marks

Explain the virtual directory properties in ASP.[5]

A Virtual Directory in ASP (Active Server Pages) is a directory name (alias) used in a URL that corresponds to a physical directory on the server. It allows web applications to be organized and accessed without exposing the actual physical path of files on the server. --- When a virtual directory...

Open this answer on its own page →