Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
ASP.NET Core 2 and Angular 5
ASP.NET Core 2 and Angular 5

ASP.NET Core 2 and Angular 5: Full-stack web development with .NET Core and Angular

Arrow left icon
Profile Icon Jürgen Gutsch Profile Icon Valerio De Sanctis
Arrow right icon
R$80 R$218.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9 (20 Ratings)
eBook Nov 2017 550 pages 1st Edition
eBook
R$80 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m
Arrow left icon
Profile Icon Jürgen Gutsch Profile Icon Valerio De Sanctis
Arrow right icon
R$80 R$218.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9 (20 Ratings)
eBook Nov 2017 550 pages 1st Edition
eBook
R$80 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m
eBook
R$80 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

ASP.NET Core 2 and Angular 5

Backend with .NET Core

Now that we have our skeleton up and running, it's time to explore the client-server interaction capabilities of our frameworks; to put it in other words, we need to understand how Angular will be able to fetch data from .NET Core using its brand new MVC and web API all-in-one structure.

We won't be worrying about how will .NET Core retrieve this data, be it from session objects, data stores, DBMS, or any possible data source; we will come to that later on. For now, we'll just put together some sample, static data in order to understand how to pass them back and forth using a well-structured, highly-configurable, and viable interface, following the same approach used by the SampleDataController shipped with the Angular SPA Template that we chose in Chapter 1, Getting Ready.

The data flow

As you might already know, a Native Web App following the Single-Page Application approach will roughly handle the client-server communication in the following way:

In our specific scenario, the index.html role is covered by the /Views/Index.cshtml view file that is returned by the Index action method within the HomeController; however, the base concept is still the same.

In case you're wondering about what these Async Data Requests actually are, the answer is simple--everything, as long as it needs to retrieve data from the server, which is something that most of the common user interactions will normally do, including (yet not limited to) pressing a button to show more data or to edit/delete something, following a link to another action view, submitting a form, and so on. That is, unless the task is so trivial--or it involves a minimal amount of data--that...

Our first ViewModel

Now that we have a clear vision of the request/response flow and its main actors, we can start building something. Our client doesn't even exist yet, but we can easily guess what we need to build it up--a set of CRUD methods for each one of the entries we identified early.

If we already used ASP.NET MVC at least once, we already know that the most straightforward way to do that is to create a dedicated Controller for each entry type. However, before adding each one of them, it can be wise to create the corresponding ViewModel so that it can handle the entry data in a strongly-typed fashion.

QuizViewModel

We might as well start with the flagship entry of our application, which will also be the most...

Adding other controllers

Now that we know the trick, we can add a bunch of other ViewMode and Controller pairs, one for each entry type we came up with earlier. In order to avoid repetition we'll skip the create file part and jump directly to the source code for each one of them, while also adding some useful hints where we need to.

QuestionViewModel

What will a quiz be without some questions? Here's how we can deal with the QuestionViewModel.cs file that we need to add within the /ViewModels/ folder:

using Newtonsoft.Json; 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

namespace TestMakerFreeWebApp.ViewModels
{
[JsonObject(MemberSerialization...

Understanding routes

In Chapter 1, Getting Ready, we acknowledged the fact that the ASP.NET Core pipeline has been completely rewritten in order to merge the MVC and WebAPI modules into a single, lightweight framework to handle both worlds. Although this is certainly a good thing, it comes with the usual downside that we need to learn a lot of new stuff. Handling routes is a perfect example of this, as the new approach defines some major breaking changes from the past.

Defining routing

The first thing we should do is to give out a proper definition of what routing actually is.

To cut it simple, we can say that URL routing is the server-side feature that allows a web developer to handle HTTP requests pointing to URIs not mapping...

Dealing with single entries

Our updated QuizController class gives us a way to retrieve a single Quiz entry; it will definitely be very useful when our users will select one of them within the Latest list, as we'll be able to point them to something similar to a detail page. It will also be very useful when we'll have to deal with CRUD operations such as Delete and Update.

We're not dealing with the client-side code yet, so we don't know how we'll present such a scenario to the user. However, we already know what we'll eventually need, a Get, Put, Post, and Delete method for each one of our entries--Quizzes, Questions, Answers, and Results--as we'll definitely have to perform these operations for all of them.

Luckily enough, we don't need to implement them now. However, since we're working with these Controllers, it can be a good time...

The data flow


As you might already know, a Native Web App following the Single-Page Application approach will roughly handle the client-server communication in the following way:

In our specific scenario, the index.html role is covered by the /Views/Index.cshtml view file that is returned by the Index action method within the HomeController; however, the base concept is still the same.

In case you're wondering about what these Async Data Requests actually are, the answer is simple--everything, as long as it needs to retrieve data from the server, which is something that most of the common user interactions will normally do, including (yet not limited to) pressing a button to show more data or to edit/delete something, following a link to another action view, submitting a form, and so on. That is, unless the task is so trivial--or it involves a minimal amount of data--that the client can entirely handle it, which means that it already has everything it needs. Examples of such tasks are show...

Our first ViewModel


Now that we have a clear vision of the request/response flow and its main actors, we can start building something. Our client doesn't even exist yet, but we can easily guess what we need to build it up--a set of CRUD methods for each one of the entries we identified early.

If we already used ASP.NET MVC at least once, we already know that the most straightforward way to do that is to create a dedicated Controller for each entry type. However, before adding each one of them, it can be wise to create the corresponding ViewModel so that it can handle the entry data in a strongly-typed fashion.

QuizViewModel

We might as well start with the flagship entry of our application, which will also be the most relevant and complex one.

Wait a minute, why are we starting with the ViewModel if we don't have a data model in place? Where will we get the data from?

Such questions are anything but trivial and deserve a concise explanation before going further. One of the biggest advantages of...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Based on the best-selling book ASP.NET Core and Angular 2
  • Easily build a complete single page application with two of the most impressive frameworks in modern development, ASP.NET Core and Angular
  • Bring together the capabilities and features of both Angular 5 and ASP.NET Core 2 for full stack development
  • Discover a comprehensive approach to building your next web project-From managing data, to application design, through to SEO optimization and security

Description

Become fluent in both frontend and backend web development by combining the impressive capabilities of ASP.NET Core 2 and Angular 5 from project setup right through the deployment phase. Full-stack web development means being able to work on both the frontend and backend portions of an application. The frontend is the part that users will see or interact with, while the backend is the underlying engine, that handles the logical flow: server configuration, data storage and retrieval, database interactions, user authentication, and more. Use the ASP.NET Core MVC framework to implement the backend with API calls and server-side routing. Learn how to put the frontend together using top-notch Angular 5 features such as two-way binding, Observables, and Dependency Injection, build the Data Model with Entity Framework Core, style the frontend with CSS/LESS for a responsive and mobile-friendly UI, handle user input with Forms and Validators, explore different authentication techniques, including the support for third-party OAuth2 providers such as Facebook, and deploy the application using Windows Server, SQL Server, and the IIS/Kestrel reverse proxy.

Who is this book for?

This book is for seasoned ASP.NET developers who already know about ASP.NET Core and Angular in general, but want to know more about them and/or understand how to blend them together to craft a production-ready SPA.

What you will learn

  • • Use ASP.NET Core to its full extent to create a versatile backend layer based on RESTful APIs
  • • Consume backend APIs with the brand new Angular 5 HttpClient and use RxJS Observers to feed the frontend UI asynchronously
  • • Implement an authentication and authorization layer using ASP.NET Identity to support user login with integrated and third-party OAuth 2 providers
  • • Configure a web application in order to accept user-defined data and persist it into the database using server-side APIs
  • • Secure your application against threats and vulnerabilities in a time efficient way
  • • Connect different aspects of the ASP. NET Core framework ecosystem and make them interact with each other for a Full-Stack web development experience

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 24, 2017
Length: 550 pages
Edition : 1st
Language : English
ISBN-13 : 9781788299787
Vendor :
Microsoft
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Nov 24, 2017
Length: 550 pages
Edition : 1st
Language : English
ISBN-13 : 9781788299787
Vendor :
Microsoft
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
R$50 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
R$500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts
R$800 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 991.97
Learning ASP.NET Core 2.0
R$272.99
C# 7.1 and .NET Core 2.0 ??? Modern Cross-Platform Development
R$445.99
ASP.NET Core 2 and Angular 5
R$272.99
Total R$ 991.97 Stars icon
Banner background image

Table of Contents

10 Chapters
Getting Ready Chevron down icon Chevron up icon
Backend with .NET Core Chevron down icon Chevron up icon
Frontend with Angular Chevron down icon Chevron up icon
Data Model with Entity Framework Core Chevron down icon Chevron up icon
Client-Server Interactions Chevron down icon Chevron up icon
Style Sheets and UI Layout Chevron down icon Chevron up icon
Forms and Data Validation Chevron down icon Chevron up icon
Authentication and Authorization Chevron down icon Chevron up icon
Advanced Topics Chevron down icon Chevron up icon
Finalization and Deployment Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9
(20 Ratings)
5 star 40%
4 star 25%
3 star 20%
2 star 15%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Wesley Davis May 19, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'm halfway through and really like this. I need to do the examples. For now I've been reading it while waiting for dinner if my .net data transfer tool to complete (hours or days) and I can't interrupt - but I can read to make the time useful. Well written. Just one thing sticks out: author uses http verbs post for update and put for insert, while the common usage is the reverse. Don't let that stop you, the book is well written.
Amazon Verified review Amazon
Brandon J. Reece Aug 01, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This has been a really good guide to get started with .Net and Angular 5
Amazon Verified review Amazon
Himanshu Rajendrabhai Patel Oct 14, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Nice book
Amazon Verified review Amazon
Scott Kuhl Dec 15, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book does an excellent job of building a complete application in Angular 5 and ASP.NET Core 2. At the time of publication and the time of this review those are both the latest versions of each framework. In the first version of this book, the author paved his own way setting up integration between Angular and ASP.NET, but in this version he used the popular JavaScriptServices project which also adds server side rendering. After reading both books, the first book feels like a beta to this finished product.One thing the author tackles, that most other authors seem to skip, is user authentication. I like that he didn't just show how to setup authentication using something like the Auth0 service but instead added authentication management right into the example.I also like that the author went through the trouble of creating a second edition only a year after the first. This is a quickly changing space and the material can get out of date fast.The only disappointment comes from the Preface. Progressive Web Apps are discussed quite a bit, including this statement:Are ASP.NET Core 2 and Angular 5 still a viable choices to deal with Progressive Web Apps, lightning-speed performance, and code simplicity?In short, the answer is yes, and the book you're about to read will do its very best to prove it.But they are never demonstrated or discussed further in the book. Its almost as if the author intended to cover the topic but did not. Hopefully the author will do some sort of online follow up or extend the third edition.
Amazon Verified review Amazon
Albertazzi Angelo Feb 25, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A parte alcune incongruenze (dovute a distrazione sicuramente es "put" invece di "post" ecc ecc"), è un ottimo libro per iniziare ad utilizzare Angular 5 e Net Core 2. Alcune "cose" sono cambiate nel template microsoft ma con qualche aggiornamento il codice funziona tranquillamente (anche aggiornando tutti i pacchetti all'ultima versione).
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.