SlideShare a Scribd company logo
1 of 24
Download to read offline
ASP.NET Core 2.1 and Angular 5 in
Visual Studio 2017
LAURENT DUVEAU
MARCH 26TH, 2018
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Laurent Duveau
@LaurentDuveau
Microsoft MVP in Montreal
Founder of the Angular Academy
2-day Angular Classroom Training
99 classes in 2 years
Montreal, Quebec, Toronto, Ottawa ,
Vancouver, Calgary, Winnipeg, London,
Copenhagen, Helsinki…
March 27-28!
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Stack Overflow Dev Survey 2018
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Agenda
Overview of ASP.NET Core + Angular in VS2017
Coding an App!
QnA
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Setup
.NET Core 2.1 Preview (Win, MacOS, and Linux)
◦ .NET Core 2.1 Preview 1 SDK
◦ .NET Core 2.1 Preview 1 Runtime
Visual Studio 2017 Preview
◦ https://www.visualstudio.com/vs/preview/
Angular Item Templates extension
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Setup
Visual Studio and Visual Studio “Preview” can be installed side-by-side.
=
VS2017 PreviewVS2017
New ASP.NET Core + Angular Project template
ASP.NET CORE 2.0 ASP.NET CORE 2.1 (PREVIEW)
7
Where is my View??
Angular
ASP.NET
MVC
API
Controller
Angular CLI
Project!
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
New ASP.NET Core + Angular Project template
We get the best of both worlds!
◦ ASP.NET Core project: act as an API backend (data access, authorization, …)
◦ Regular Angular CLI project (ClientApp folder): act as a UI web app
The template offers the convenience of hosting both project
types in a single Visual Studio project, that can be built and
published as a single unit.
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Architecture
ASP.NET Core
Web API (RESTFUL)
Server side
Client side
Database
HTML
+ Js
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
New Project template
Angular CLI
◦ Built-in commands: ng serve, ng test, ng lint, …
◦ Easier to follow Angular versions (ng update!)
Webpack middleware integration
◦ In dev, you don’t need to keep rebuilding your client-side application
Hot module replacement
◦ Any file changed is pushed into the browser immediately without
reloading the page
Demo
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Or just using dotnet cli…
Step 1: Install the templates
Step 2: Create a new Angular App
Step 3: Change Environment variable to “Development”
Step 4: Build the application (restore npm dependencies on the first run…)
Step 5: Finally, run the app
dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0
dotnet new angular
SET ASPNETCORE_Environment=Development
dotnet build
dotnet run
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Already familiar with Angular CLI?
No need to run ng serve!
By default the ASP.NET Core app deals with serving both server-
side and client-side parts of your app (Internally, it uses ng
serve).
But it can be slow…
Each time you modify your C# code, the ASP.NET Core app
needs to restart, and the Angular CLI server restarts.
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Run "ng serve" independently!
Startup.cs
◦ Replace:
◦ With:
Now just ng serve in your ClientApp folder!
spa.UseAngularCliServer(npmScript: "start");
spa.UseAngularCliServer("http://localhost:4200");
Demo
Let’s talk about Angular
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Angular Core Concepts
Components Modules
Dependency
Injection
Language
(TypeScript)
Services Data Binding Decorators Routing
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Building SPAs with Components
Header Component
Menu
Component
Footer Component
List ComponentGrid Component
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
What is a Component?
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
What is a Component?
A component is a reusable object
Made up of: HTML
Template
Code
(ts class)
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Map Update
App
DetailsList
ProductsMenu Contact
Your app is a tree of Components
Demo
ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018
Angular classroom training
Tomorrow in Ottawa!
Get 50% OFF with
promo code OTTUG50
Thank you!

More Related Content

More from Laurent Duveau

More from Laurent Duveau (20)

TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
 
Introduction to Angular with TypeScript for .NET Developers
Introduction to Angular with TypeScript for .NET DevelopersIntroduction to Angular with TypeScript for .NET Developers
Introduction to Angular with TypeScript for .NET Developers
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
 
Introduction à Angular 2
Introduction à Angular 2Introduction à Angular 2
Introduction à Angular 2
 
Angular 2... so can I use it now??
Angular 2... so can I use it now??Angular 2... so can I use it now??
Angular 2... so can I use it now??
 
ngconf 2016 (french)
ngconf 2016 (french)ngconf 2016 (french)
ngconf 2016 (french)
 
Microsoft Edge pour les développeurs web
Microsoft Edge pour les développeurs webMicrosoft Edge pour les développeurs web
Microsoft Edge pour les développeurs web
 
Microsoft Edge pour les développeurs web
Microsoft Edge pour les développeurs webMicrosoft Edge pour les développeurs web
Microsoft Edge pour les développeurs web
 
Introduction to SPAs with AngularJS
Introduction to SPAs with AngularJSIntroduction to SPAs with AngularJS
Introduction to SPAs with AngularJS
 
Xamarin.Forms [french]
Xamarin.Forms [french]Xamarin.Forms [french]
Xamarin.Forms [french]
 
Back from Xamarin Evolve 2014
Back from Xamarin Evolve 2014Back from Xamarin Evolve 2014
Back from Xamarin Evolve 2014
 
Windows App Studio
Windows App StudioWindows App Studio
Windows App Studio
 
Windows 8: Live tiles, badges et notifications toasts [french]
Windows 8: Live tiles, badges et notifications toasts [french]Windows 8: Live tiles, badges et notifications toasts [french]
Windows 8: Live tiles, badges et notifications toasts [french]
 
L'opportunité Windows 8 pour les développeurs
L'opportunité Windows 8 pour les développeursL'opportunité Windows 8 pour les développeurs
L'opportunité Windows 8 pour les développeurs
 
Building apps for WP8 and Win8
Building apps for WP8 and Win8Building apps for WP8 and Win8
Building apps for WP8 and Win8
 
Windows Store apps development
Windows Store apps developmentWindows Store apps development
Windows Store apps development
 
L'opportunité Windows 8: Introduction au Windows Store
L'opportunité Windows 8: Introduction au Windows StoreL'opportunité Windows 8: Introduction au Windows Store
L'opportunité Windows 8: Introduction au Windows Store
 
Introduction au Windows Store
Introduction au Windows StoreIntroduction au Windows Store
Introduction au Windows Store
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

ASP.NET Core 2.1 and Angular 5 in Visual Studio 2017

  • 1. ASP.NET Core 2.1 and Angular 5 in Visual Studio 2017 LAURENT DUVEAU MARCH 26TH, 2018
  • 2. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Laurent Duveau @LaurentDuveau Microsoft MVP in Montreal Founder of the Angular Academy 2-day Angular Classroom Training 99 classes in 2 years Montreal, Quebec, Toronto, Ottawa , Vancouver, Calgary, Winnipeg, London, Copenhagen, Helsinki… March 27-28!
  • 3. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Stack Overflow Dev Survey 2018
  • 4. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Agenda Overview of ASP.NET Core + Angular in VS2017 Coding an App! QnA
  • 5. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Setup .NET Core 2.1 Preview (Win, MacOS, and Linux) ◦ .NET Core 2.1 Preview 1 SDK ◦ .NET Core 2.1 Preview 1 Runtime Visual Studio 2017 Preview ◦ https://www.visualstudio.com/vs/preview/ Angular Item Templates extension
  • 6. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Setup Visual Studio and Visual Studio “Preview” can be installed side-by-side. = VS2017 PreviewVS2017
  • 7. New ASP.NET Core + Angular Project template ASP.NET CORE 2.0 ASP.NET CORE 2.1 (PREVIEW) 7 Where is my View?? Angular ASP.NET MVC API Controller Angular CLI Project!
  • 8. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 New ASP.NET Core + Angular Project template We get the best of both worlds! ◦ ASP.NET Core project: act as an API backend (data access, authorization, …) ◦ Regular Angular CLI project (ClientApp folder): act as a UI web app The template offers the convenience of hosting both project types in a single Visual Studio project, that can be built and published as a single unit.
  • 9. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Architecture ASP.NET Core Web API (RESTFUL) Server side Client side Database HTML + Js
  • 10. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 New Project template Angular CLI ◦ Built-in commands: ng serve, ng test, ng lint, … ◦ Easier to follow Angular versions (ng update!) Webpack middleware integration ◦ In dev, you don’t need to keep rebuilding your client-side application Hot module replacement ◦ Any file changed is pushed into the browser immediately without reloading the page
  • 11. Demo
  • 12. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Or just using dotnet cli… Step 1: Install the templates Step 2: Create a new Angular App Step 3: Change Environment variable to “Development” Step 4: Build the application (restore npm dependencies on the first run…) Step 5: Finally, run the app dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0 dotnet new angular SET ASPNETCORE_Environment=Development dotnet build dotnet run
  • 13. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Already familiar with Angular CLI? No need to run ng serve! By default the ASP.NET Core app deals with serving both server- side and client-side parts of your app (Internally, it uses ng serve). But it can be slow… Each time you modify your C# code, the ASP.NET Core app needs to restart, and the Angular CLI server restarts.
  • 14. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Run "ng serve" independently! Startup.cs ◦ Replace: ◦ With: Now just ng serve in your ClientApp folder! spa.UseAngularCliServer(npmScript: "start"); spa.UseAngularCliServer("http://localhost:4200");
  • 15. Demo
  • 17. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Angular Core Concepts Components Modules Dependency Injection Language (TypeScript) Services Data Binding Decorators Routing
  • 18. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Building SPAs with Components Header Component Menu Component Footer Component List ComponentGrid Component
  • 19. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 What is a Component?
  • 20. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 What is a Component? A component is a reusable object Made up of: HTML Template Code (ts class)
  • 21. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Map Update App DetailsList ProductsMenu Contact Your app is a tree of Components
  • 22. Demo
  • 23. ASP.NET Core 2 and Angular 5 in Visual Studio 2017 Ottawa IT Community, march 2018 Angular classroom training Tomorrow in Ottawa! Get 50% OFF with promo code OTTUG50