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
$48.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9 (20 Ratings)
Paperback Nov 2017 550 pages 1st Edition
eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Jürgen Gutsch Profile Icon Valerio De Sanctis
Arrow right icon
$48.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9 (20 Ratings)
Paperback Nov 2017 550 pages 1st Edition
eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery fee Deliver to Japan

Standard delivery 10 - 13 business days

$8.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

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 : 9781788293600
Vendor :
Microsoft
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Japan

Standard delivery 10 - 13 business days

$8.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 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
$199.99 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 $5 each
Feature tick icon Exclusive print discounts
$279.99 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 $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 177.97
Learning ASP.NET Core 2.0
$48.99
C# 7.1 and .NET Core 2.0 ??? Modern Cross-Platform Development
$79.99
ASP.NET Core 2 and Angular 5
$48.99
Total $ 177.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

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela