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

Wire it up!

Now that we have our solution infrastructure in place, in this module we are going to connect the two projects and set up communication between the font-end and the back-end.

Table Of Contents
  1. Configure the Web API Project
  2. Configure the Startup Projects
  3. Configure the Angular WebAPI Requests
  4. Give it a whirl
  5. Launching your preferred browser
  6. What's Next

Configure the Web API Project

From Solution Explorer open the FredsCarsAPI/Properties/launchSettings.json file.

Set all the values for “launchBrowser” to false. And change all the HTTP values to the fixed port 40080 and the HTTPS values to the fixed port 40443.

{
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:40080",
      "sslPort": 40443

    }
  },
  "profiles": {
    "http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": false,
      "launchUrl": "swagger",
      "applicationUrl": "http://localhost:40080",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": false,
      "launchUrl": "swagger",
      "applicationUrl": "https://localhost:40443;http://localhost:40080",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": false,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

In the above configuration file we are setting launchBrowser for all the profiles to false. Otherwise the API project would launch Swagger everytime we start up the project to test and debug. We don’t want that right now. We’ll talk more about Swagger in later modules. It’s a nice tool to automatically document and test your WebAPI Rest Services.

We also set all the HTTP and HTTPS values to fixed ports so that we can easily reach the API project from Angular no matter what profile we are running the WebAPI project with.

Configure the Startup Projects

Right click the FredsCars solution in Solution Explorer and select Properties.

Under Startup Project, select “Multiple Startup Projects”. Set the Action for both projects to Start. Select the FredsCarsAPI project and click the up arrow to move FredsCarsAPI to the first position. This will make FredsCarsAPI start first so that when the Angular project starts up the WebAPI will already be available to serve data for Angular to consume.

Configure the Angular WebAPI Requests

Open the FredsCars/src/proxy.conf.js file in the Angular project. This is the proxy file used by the Angular Development Server to communicate with the back-end WebAPI in debug mode. Make the following code change highlighted in blue.

const PROXY_CONFIG = [
  {
    context: [
      "/weatherforecast",
    ],
    target: "https://localhost:40443",
    secure: false
  }
]

module.exports = PROXY_CONFIG;

In the above code we have changed the randomly generated port to the fixed HTTPS port we assigned to the WebAPI project.

Give it a whirl

Now that we have configured and wired everything up, let’s test out what we have so far.

Click the Green Start button in the top toolbar or press the F5 key to start the project in debug mode.

If you get a popup asking if you would like to trust the self signed certificate, click yes.

You’ll see messages in the Visual Studio output window that both projects are building and then messages about the deployment process. This can take a while the first time.

Next the ASP.Net Core Kestrel Server will startup in a console window to host the WebAPI project and you will see the WebAPI project listening on the HTTP and HTTPS ports we assigned it earlier in the FredsCarsAPI launchSettings.json file.

Another console window will then open hosting the Angular Live Development Server. You’ll see a message that the Angular compilation process is “generating browser application bundles”.

When the compilation process is finally complete, you should see the message “Compiled Successfully” and that the Angular application is listening on port 4200.

Finally a browser window will open and you can see the Angular root component is calling the single existing WeatherForecast API Service in the back-end WebAPI project and it’s HTML template is displaying the results.

Launching your preferred browser

You can see in the screenshot above that Angular launched the Microsoft Edge Browser. I prefer to work with Chrome when I am developing. Let’s fix that right now.

Open up the FredsCars/.vscode/launch.json file in Solution Explorer. The .vscode folder is a hidden folder in Visual Studio, so you may need to click the “Show All Files” button in the toolbar at the top of Solution Explorer to see it.

Then simply move the Chrome configuration from the bottom to the top above Edge.

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "localhost (Chrome)",
      "url": "https://localhost:4200",
      "webRoot": "${workspaceFolder}"
    },
    {
      "type": "edge",
      "request": "launch",
      "name": "localhost (Edge)",
      "url": "https://localhost:4200",
      "webRoot": "${workspaceFolder}"
    }
  ]
}

If you haven’t stopped debugging press the red stop button in Visual Studio, press Shift-F5 on your keyboard, or simply close the browser window in debug mode and restart the application in debug mode.

When the application starts up again Angular will now have started up the Chrome browser rather then Edge.

What’s Next

We finally have all of our infrastructure in place. We have a solution with two projects. The back-end ASP.Net Core WebAPI project, and the front-end Standalone Typescript Angular project. And they can talk to each other allowing the Angular application to make API calls to our back-end and display results. In the next few modules we will get a better idea of how this is all working and start to build out our beloved FredsCars dealership in a full stack architecture as promised.

< 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