Tricky Talks (or TWS Blog)
Your Go-To Hub for IT Skills, Development Tips, and Tech Trends
Getting Started with .NET 9: A Beginner’s Guide to Building Your First Web App
- Posted By: trickywebsolutions
-
June 10, 2025

Welcome to the world of .NET 9! If you’re new to .NET or web development, this .NET 9 tutorial will walk you through the essentials of building your first web application using ASP.NET Core 9. Learn .NET 9 step by step as we guide you through its powerful features and enhancements that make web development more streamlined and efficient. In this blog, we’ll show you the complete process of how to build web app using .NET 9 — from setup to deployment.
What is a Web App?
A web application is an interactive computer program written with web technologies like HTML, CSS, and JavaScript. It keeps data (through databases or files), performs data manipulation (CRUD operations), and is accessed by individuals or teams to accomplish tasks via the internet.
These programs are accessed via web browsers, where users engage with them. All computation is on the server end instead of the client end, so users do not need to install certain operating systems or programming languages on their devices, contrary to what happens with regular desktop applications or mobile apps.
More broadly, a web application is a type of software program that works using a web browser. Examples of web apps include Figma, Canva, HubSpot, and Trello. Web apps do not include standard websites, the majority of desktop-installed software, and native mobile apps.
Usually, web apps are cloud-hosted. But there are exceptions—web apps can be self-hosted and run on local boxes or in on-premises infrastructure, still accessible through a web browser.
What is .NET 9?
Being the latest version of Microsoft’s open-source, cross-platform development framework, .NET 9 enables developers to build robust, modern applications across different domains, including web, desktop, mobile, and cloud platforms. With the advanced features and improvements such as enhanced security, improved support for cloud-based architectures, .NET 9 allows developers to build optimized web applications and helps them with developing, testing, and deploying apps across the platform.
.NET 9, the newest version of .NET 8, is created with high-performance optimization and cloud-native application development in mind. Being a STS release, it will see updates and support for 18 months. Its purpose is to ease development by improving speed, reliability, and security, as well as bringing new language enhancements to make coding easier.
How to Build Web App Using .NET 9: .NET 9 Tutorial
Here we have given the complete step by step .NET 9 tutorial on how to build web app with .NET 9:
Prerequisites
Before you start and writing code make sure the following setups are done:
.NET 9 SDK: This is the core software development kit that enables you to create, develop, and run .NET 9 applications. Install it from the .NET download page.
Editor Options
- Visual Studio 2022, This IDE offers a full development experience with debugging, templates, and integrated tools.
- Visual Studio Code with the C# extension. This light code editor is perfect if you like a lighter setup.
Step 1: Create the Project
dotnet new razor -n MyDotNet9App
cd MyDotNet9App
Code Explanation:
- The command dotnet new razor scaffolds a new Razor Pages web application template.
- The -n MyDotNet9App parameter sets the project name.
- cd MyDotNet9App navigates into the newly created project folder.
At this point, you have a basic, working web application ready for customization.
Step 2: Explore the Project Structure
Understanding the project layout helps you navigate and customize your app effectively. Here are some key parts of your new app:
Pages/Index.cshtml: This is the main homepage view written in Razor markup, combining HTML and C#.
Pages/Index.cshtml.cs: The associated Page Model file containing the server-side C# code that supports the page’s logic and data.
Program.cs: This file configures and starts your web application, setting up middleware, services, and request routing.
wwwroot/: The folder for static files such as CSS stylesheets, JavaScript files, and images that the app serves directly to the browser.
Step 3: Modify the Home Page
Now, customize the home page to interact with the user. Open Pages/Index.cshtml and replace the existing content with the following:
@page
@model IndexModel
<h1>@ViewData["Title"]</h1>
<p>This is your first web app built using .NET 9!</p>
<form method="post">
<input type="text" name="username" placeholder="Enter your name" />
<button type="submit">Submit</button>
</form>
@if (!string.IsNullOrEmpty(Model.Message))
{
<p>@Model.Message</p>
}
This code sets a page title, displays a greeting message, and includes a simple form where users can enter their name.
Next, update the backend logic by editing Pages/Index.cshtml.cs:
public class IndexModel : PageModel {
[BindProperty] public string? Username { get; set; }
public string? Message { get; set; }
public void OnPost() {
if (!string.IsNullOrWhiteSpace(Username))
Message = $"Hello, {Username}! Welcome to .NET 9.";
}
}
When the form is submitted (POST request), the OnPost method runs, setting a personalized greeting message that displays on the page.
Step 4: Run the App
Run your application to see it in action.
In the terminal, type:
dotnet run
Alternatively, press F5 if you’re using Visual Studio to launch the app with debugging enabled.
Visit http://localhost:5000 to test it live.
Step 5: Next Steps & Ideas
This basic app is a good starting point to build upon. Here are some possible ways to expand its features:
Add Multiple Pages: Add more Razor Pages for About, Contact, or any other pages with routing to go between them.
Database Integration: Integrate Entity Framework Core to link your app to a database, where you can store user input or other data.
Dependency Injection: Insert services that hide business logic to enhance modularity and testability.
Layouts and Styling: Insert a common layout page (_Layout.cshtml) for uniform navigation, headers, and footers, and use CSS for enhanced visuals.
Deployment: Once ready, deploy your app and host it on cloud platforms such as Azure, AWS, or self-host.
Publishing the App
When your application is ready for production, you can publish it by running:
dotnet publish -c Release -o ./publish
With these steps, you have created a fully functional, simple web app using .NET 9 and Razor Pages. As you become more comfortable, you can explore the many features of .NET 9 to create complex, scalable, and secure web applications.