Skip to content
  • iImagine
  • Register
  • Log In

Web Development School

Learning made easy.

  • Books
    • Beginning Web Development with ASP.Net Core & Client-Side Technologies
      • TOC
      • Part 1
        • Chapter 1: Static HTML – Designing the landing page
      • Part 2
        • Chapter 2: ASP.Net Core – Let’s talk Dynamic
        • Chapter 3: Introduction to ASP.Net Core MVC
          [ASP.Net Core v9]
      • Part 4
        • Chapter 7: Using Server Side & Client Side technologies together
          [ASP.Net Core v7 & Angular 15]
  • Environment Setup
    • Installing Angular
    • Installing Visual Studio 2022
    • Installing SQL Server 2022 Express
    • Installing Postman
    • Installing Git for Windows
  • Blog
  • iImagine WebSolutions
  • Events
  • Learning Videos
  • Toggle search form

Add an ASP.Net Core Web API project

Now we want to create the Web API project for FredsCars that will serve as the backend of the application and serve data to the Angular project.

Table Of Contents
  1. Explore available Dotnet projects
  2. Create the Web API project
  3. Run the Web API project
  4. What's Next

Explore available Dotnet projects

Let’s use the Dotnet CLI again to see what kind of Dotnet projects are actually available to create.

Type the following command in a command window.

dotnet new list

A list of all the Dotnet project types is then shown. And we want to use the ASP.Net Core Web API Template.

The template name is kind of the full name of the project template. The short name is what we would use if we create the project from the command line. We can also create each project type from a GUI Wizard within Visual Studio. This process has become cumbersome and error prone over the years (one reason being because there are so many project types now) and using the Dotnet CLI has become the more efficient way to go. But it’s good to be able to walk through the wizards in the beginning to get a better idea of what’s going on.

So let’s do it! Let’s create the Web API project.

Create the Web API project

With the FredsCars solution open in Visual Studio where we left off in module 4, “Create the Visual Studio Solution“, right click the solution and select “Add –> New Project”.

The “Add a new project” dialogue will pop up. Type “ASP.Net Core Web API in the search box. Select “ASP.Net Core Web API” for C#. Be carful not to select the project type for F#. Click Next.

The “Configure your new project” dialogue will appear. Set the Project name to “FredsCarsAPI” and click Next.

The “Additional information” dialogue will appear. Under Framework select .Net 7.0. Leave the defaults for the rest of the options. Click Create.

And that’s it. You’ll see a message saying “Creating Project” and when the process is complete the Web API project will be under the solution in Solution Explorer.

Run the Web API project

In a command window change directories to the new FredsCarsAPI folder with the following command.

cd C:\Development\FredsCars\FullStack\Module04\FredsCarsAPI

Then type the following command.

dotnet run --launch-profile "https"

Once the project is done building, you’ll see that it is up and running in ASP.Net Core’s built in web server in development mode. It is actually listening on two different ports. One is using HTTP (Hypertext Transfer Protocol) and the other is using (Hypertext Transfer Protocol Secure) with encryption.

Open up an instance of the Chrome browser and navigate to the https url address shown in your command window with “/WeatherForecast” tacked on the end like this:

https://localhost:7042/WeatherForecast

Of course, you’ll need to change the random port in your URL:

https://localhost:[replace random port here]/WeatherForecast

You’ll see that a list of five WeatherForecast objects have been returned in an array in JSON format in the browser window. JSON data is kind of hard to read when returned directly in a browser window but it is easier to read if you view the results from inside the development tools.

In the above screenshot I hit the F12 key on the keyboard, went to the Network tab in the top toolbar of the development tools, and for the WeatherForecast request I clicked Preview. Here you can see the WeatherForcast JSON array formatted nicely.

What’s Next

So far we have created the Visual Studio solution file and added the Web API project to it. In the next module we will add a “Stand Alone Angular TypeScript” project to the solution.

< Prev
Next >

Leave a ReplyCancel reply

Chapter 1: Static HTML – Designing the landing page.

  • Static HTML – Designing the landing page.
  • Let’s get started!
  • Mock your site with HTML
  • Make CSS easy with Bootstrap
  • Mock your content
  • Introducing JavaScript
  • JavaScript Code Improvements
  • Results Data
  • Images and the HTML Image Element.
  • Revisiting Reusability for CSS and JavaScript
  • Reuse for HTML: PART 1
  • Reuse for HTML: PART 2
  • Details Page – Using a Bootstrap Component
  • Creating Links
  • Chapter One Conclusion

Chapter 2: ASP.Net Core – Let’s talk Dynamic

  • Introduction to ASP.Net Core
  • What is .Net?
  • What is ASP.Net
  • Introduction to Entity Framework Core

Chapter 3: ASP.Net MVC Core – Models, Views, and Controllers [ASP.Net Core v9]

  • Introduction to ASP.Net Core MVC
  • Create the project: ASP.Net Core MVC
  • Explore the ASP.Net Core Empty Web Project Template
  • Configure the Application for MVC
  • Create a Controller: Home Controller
  • Create a View: Index View for the Home Controller
  • Install Bootstrap using Libman
  • Create the Layout template
  • Create the Model
  • Install EF Core & Create the Database
  • Seed the Database: Loading test data
  • DI (Dependency Injection): Display a List of Vehicles
  • Repository Pattern: The Vehicles Repo
  • Unit Test 1: Home Controller Can Use Vehicle Repository
  • Unit Test 2: Vehicle Repository Can Return List
  • Add the ImagePath Migration and Thumbnail images to results
  • Pagination: Create a Custom Tag Helper
  • Sorting
  • Category Filter
  • Partial View: Break out the vehicle results
  • View Component: Create dynamic category buttons
  • Create the Details page
  • Create the Create Page

Chapter 7: Using Server Side & Client Side technologies together. [ASP.Net Core v7 & Angular v15]

  • Intro to Full Stack Development
  • Fred’s Cars – Full Stack Development
  • Prepare the environment
  • Create the Visual Studio Solution
  • Add the ASP.Net Core Web API project
  • Add the Angular Project
  • Wire it up!
  • WeatherForecast: Understanding the basics
  • Vehicles API Controller: Mock Data
  • Vehicles Angular Component: Consuming Data
  • Routing and Navigation
  • Using a Component Library: Angular Material
  • Our first Angular Material Component: MatToolbar
  • Configuring for Saas: CSS with superpowers
  • Create the Header & Footer components
  • Displaying Results with MatTable
  • Loading: Using a Progress Spinner
  • MatTable: Client-Side Paging and Sorting
  • MatSidenav: Create a Search Sidebar
  • MatCheckbox: Category Search UI
  • Adding an image to the welcome page
  • Create the database with Entity Framework Core migrations
  • MatPaginator & PageEvent: Custom Server-Side Paging
  • Unit Testing: Custom Server-Side Paging
  • Repository Pattern: VehicleRepository
  • Unit Test: Paging in the Vehicles controller
  • Server-Side Sorting
  • Unit Tests: Sorting
  • Filter (Quick Search)
  • Unit Tests: Filter feature
  • Advanced Search: Categories
  • Unit Tests: Search by category
  • Progress Spinner: Final Fix

TOC

  • What were WebForms?
  • Enter MVC
    • Understanding MVC
    • Advantages of MVC
  • ASP.Net Core MVC – A total rewrite
  • ASP.Net Core 2 MVC – Here come Razor Pages
    • Understanding Razor Pages
  • ASP.Net Core 3 – Dropping the MVC reference
    • Understanding Blazor
  • Dropping the MVC reference
  • Hello .Net 5!
  • What’s Next? – Here comes .Net 6.

Recent Posts

  • Angular Commands Cheat Sheet
  • Installing Git for Windows
  • Installing Postman
  • Installing SQL Server 2022 Express
  • Installing Visual Studio 2022

Recent Comments

No comments to show.

Archives

  • November 2023
  • October 2023
  • June 2023
  • October 2021

Categories

  • Angular
  • ASP.Net
  • Environment Setup
  • See All
  • SQL Server
  • Visual Studio
  • Web API & Rest Services

WordPress Theme Editor

Copyright © 2025 Web Development School.

Powered by PressBook Blog WordPress theme