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.
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 answerHide 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 Releasespecifies the Release configuration (optimized build)-o ./publishspecifies 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
| Step | Command | Purpose |
|---|---|---|
| Verify CLI | dotnet | Check installation |
| Create App | dotnet new console | Initialize project |
| Restore | dotnet restore | Download dependencies |
| Build | dotnet build | Compile source code |
| Run | dotnet run | Test locally |
| Publish | dotnet publish | Prepare 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.
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]
2078 · 5 marks
Explain the process to deploy the core application. [5]
Make Unit 9 stick
Practice CSC378 with flashcards & quizzes