Guozhen AIGlobal AI field notes and model intelligence

English translation

7. Creating Your First ASP.NET Core Application: Project Setup

Published:

Category: ASP.NET

Read time: 3 min

Reads: 0

Lesson #7Views are counted together with the original Chinese articleImages are preserved from the source page

AI Article Decision Snapshot

Turn the lesson into workflow, model, budget, and security checks before choosing tools.

Use this quick snapshot before leaving the article. It keeps the next search tied to practical AI software, model/API, cost, privacy, and implementation questions.

Workflow fit

Identify the real job behind the article: coding, research, document review, support, analytics, content, or internal automation.

Model or tool decision

Decide whether the next step is a software shortlist, an AI tool comparison, an API platform choice, or a model benchmark.

Budget and usage signal

Estimate seats, API calls, prompt volume, retries, review time, and fallback work before assuming the workflow is cheap.

Security and privacy review

Check whether source code, customer data, private documents, prompts, logs, or embeddings will enter the AI workflow.

In the previous article, we explored how to select an appropriate IDE to prepare for ASP.NET Core development. Now, we begin our journey building our first ASP.NET Core application—specifically, learning how to create a new ASP.NET Core project.

Creating an ASP.NET Core Project

Step 1: Launch Your IDE

First, open your chosen IDE—commonly Visual Studio, Visual Studio Code, or JetBrains Rider. Below are instructions for creating an ASP.NET Core project in each environment.

Creating a Project in Visual Studio

  1. Launch Visual Studio.
  2. In the Start Window, select Create a new project.
  3. In the Create a new project dialog, search for “ASP.NET Core Web App”, then select it and click Next.
  4. Enter a project name and choose a save location, then click Create.
  5. In the next dialog, select the Web App (Model-View-Controller) template. Ensure the correct target framework is selected (e.g., .NET 6.0 or .NET 7.0), then click Create.

Creating a Project in Visual Studio Code

  1. Ensure the .NET SDK is installed on your system.

  2. Open a terminal and navigate to the directory where you want to create the project.

  3. Run the following command to generate a new MVC project:

    dotnet new mvc -n MyFirstApp
    

    Here, MyFirstApp is your project name. This command creates a new ASP.NET Core MVC project.

  4. Open the project in VS Code using:

    cd MyFirstApp
    code .
    

Step 2: Overview of Project Structure

After project creation, you’ll see a set of files and folders. Understanding their purpose helps you organize and manage your application effectively. A typical ASP.NET Core MVC project has the following structure:

MyFirstApp/
├── Controllers/
│   └── HomeController.cs
├── Models/
├── Views/
│   └── Home/
│       └── Index.cshtml
├── wwwroot/
│   ├── css/
│   ├── js/
│   └── lib/
├── appsettings.json
├── Program.cs
└── MyFirstApp.csproj

⚠️ Note: In newer versions of ASP.NET Core (starting with .NET 6), Startup.cs has been replaced by configuration logic embedded directly in Program.cs. The Startup.cs file no longer appears by default.

Key Files and Folders Explained

  • Controllers/: Contains controller classes that handle incoming HTTP requests and return responses.
  • Models/: Holds data model classes—typically used to represent domain entities or data-transfer objects.
  • Views/: Stores Razor view templates (.cshtml files) responsible for rendering HTML to users.
  • wwwroot/: Serves static web assets such as CSS, JavaScript, images, and third-party libraries.
  • appsettings.json: Stores configuration settings—for example, connection strings, logging options, or custom app settings.
  • Program.cs: The application’s entry point and central configuration file, where services, middleware, and routing are configured.

Step 3: Running the Application

Once the project is created, run it to view the default welcome page:

dotnet run

In the terminal, you’ll see output including a URL like https://localhost:5001. Open this address in your browser to view the default landing page.

Example: Building a Simple Welcome Page

Let’s build a simple “Welcome” page to reinforce how controllers and views work together.

Creating a Controller

Inside the Controllers folder, create a new file named WelcomeController.cs, and add the following code:

using Microsoft.AspNetCore.Mvc;

namespace MyFirstApp.Controllers
{
    public class WelcomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }
    }
}

Creating a View

Inside the Views folder, create a subfolder named Welcome, then inside it create a file named Index.cshtml with the following content:

@{
    ViewData["Title"] = "Welcome";
}

<h1>Welcome to ASP.NET Core!</h1>
<p>This is your first ASP.NET Core application.</p>

Configuring Routing

Finally, update the default route in Program.cs. Locate the app.UseEndpoints(...) block and replace it with:

app.UseEndpoints(endpoints =>
{
    endpoints.MapControllerRoute(
        name: "default",
        pattern: "{controller=Welcome}/{action=Index}/{id?}");
});

✅ Tip: In modern ASP.NET Core (6.0+), routing is typically configured in Program.cs, not Startup.cs.

Step 4: Run the Application Again

After saving all changes, run the app again:

dotnet run

Navigate to https://localhost:5001 in your browser—you’ll now see your custom Welcome page.

Summary

In this section, we learned how to create a new ASP.NET Core project, explored its fundamental structure, and added a basic controller and view. In the next article, we’ll dive deeper into the project architecture—examining how components interact and how ASP.NET Core’s request pipeline operates—to strengthen your foundational understanding.

Stay tuned for the next installment—we’ll continue exploring ASP.NET Core together!

Apply This Lesson

Turn this article into AI software, model, API, and security decisions.

English Article FAQ

Use this article as evidence before choosing AI tools

How should I use this AI Tutorials article?

Use it as the implementation or learning layer, then connect the idea to AI software buyer guides, tool comparisons, benchmarks, API choices, and security checks before making a production decision.

Is this English article different from the Chinese original?

The English edition is localized for global AI readers while preserving the original diagrams, screenshots, prompts, code examples, and source context from the Chinese article.

What should I read after 7. Creating Your First ASP.NET Core Application: Project Setup?

Continue with AI Software Buyer Guides, AI Tools Workbench, Best AI Coding Agents, AI Model Benchmarks, OpenAI vs Anthropic API, or LLM Security Tools depending on the decision you need to make.

Can this article alone choose an AI product or model?

No. Treat the article as evidence and context, then validate fit with pricing, privacy requirements, integration effort, benchmark results, workflow tests, and fallback planning.

Continue

Keep reading from here

Browse English site

Reader Messages

Reader messages

Questions, corrections, extra sources, or hands-on results can be left here. No login is required.

Max 800 characters

To reduce spam, each message is checked for length, link count, and posting frequency.

0/800

Messages

0 messages
Loading messages...