Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
ASP.NET Core and Angular 2
ASP.NET Core and Angular 2
Credits
About the Author
About the Reviewer
www.PacktPub.com
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Ready
Two players one goal
What's new in Angular 2?
The ASP.NET Core revolution
The field of choice – single-page application
Common features of a competitive SPA
Product owner expectations
A sample single-page application project
The vision
Core requirements
Preparing the workspace
Setting up the project
Package and resource managers
Installing the packages
NuGet and ASP.NET
Project.json
Startup.cs
Testing the HTTP request pipeline
Newtonsoft.Json
JavaScript, TypeScript, or Dart?
Adding the tsconfig.json file
Introducing NPM
Working with Gulp
Dependent tasks
Using Grunt instead of Gulp
Adding Angular 2
Using NPM
Adding Typings
Using a CDN
Upgrading the typescriptServices.js file
Setting up the client code
The component file
A word on components and modules
The module file
The bootstrap file
The module loader configuration file
Why use a dynamic module loader?
The index.html file
First run
Caching issues
The new ASP.NET Core configuration pattern
A faster alternative using scaffolding tools
The reasons to say no (not yet)
A quick scaffolding sample
References
Suggested topics
Summary
2. ASP.NET Controllers and Server-Side Routes
Data flow
The role of the ViewModel
Our first Controller
The ItemViewModel
The ItemsController
Understanding routes
Defining routing
Routing through the ages
Handling routes in ASP.NET Core
Convention-based routing
Attribute-based routing
Three choices to route them all
Adding more routes
The dummy data provider
Dealing with single items
Suggested topics
Summary
3. Angular 2 Components and Client-Side Routing
Master-detail binding
The Item class
The ItemService class
The ItemListComponent class
A quick implementation test
The ItemDetailComponent class
Adding the @angular/forms library
Updating the root module
Connecting the dots
Testing it up
Adding additional lists
Multiple component instances
Two-way data binding
Disabling two-way data binding
Client-side routing
Adding the @angular/router library
PathLocationStrategy versus HashLocationStrategy
Refactoring our app
Adding the AppRouting scheme
Adding the HomeComponent
Adding new components
AboutComponent
LoginComponent
PageNotFoundComponent
Updating the root module
Revising the master-detail strategy
Adding the ItemDetail route
Changing the ItemListComponent
Updating the ItemDetailComponent
Full routing test
Handling rewrites in ASP.NET Core
Showing the issue
Understanding the causes
Implementing the fix
Validating the outcome
Suggested topics
Summary
4. The Data Model
Getting ready
Installing the EntityFramework Core
Data modeling approaches
The model-first approach
Pros
Cons
The database-first approach
Pros
Cons
The code-first approach
Pros
Cons
Making a choice
Creating entities
Items
Comments
Users
Defining relationships
Setting up DbContext
Database initialization strategies
Choosing the database engine
Updating appsettings.json
Creating the database
Updating Startup.cs
Configuring the EF tools
Adding the initial migration
Understanding migrations
Implementing a data seed strategy
Creating a DbSeeder class
Private members
Constructor
Public methods
Seed methods
Utility methods
Adding the DbSeeder to Startup.cs
Handling exceptions
Seeding the database
Updating the ItemsController
Installing TinyMapper
Implementing the mapping
Testing the data provider
Suggested topics
Summary
5. Persisting Changes
Add, update, and delete items
Updating the Web API
Adapting the client
Improving the ItemService
Updating the GUI
Add new
Update and Delete
Testing it out
Adding a new test
Update test
Delete test
Splitting the ItemDetail component
Adding the ItemDetailView component
Refactoring ItemDetail into ItemDetailEdit
Updating the Root module
Updating the Routes
Tracking the outdated references
Implementing the tab menu
Template
Class code
Styles
Testing it out
Suggested topics
Summary
6. Applying Styles
How bad is it, doc?
Introducing LESS
Style sheet languages
CSS
CSS code sample
What is LESS and why to use it
Variables
Import directives
Nested selectors
Mixins
Extend pseudo-class
LESS docs and support
Systematically Awesome Style Sheets, Stylus, and other alternatives
Configuring LESS
Adding the LESS file
Updating Gulp script
Linking the stylesheet
Testing it up
DIY versus framework-based styling
Do it yourself approach
Pros
Cons
Framework-based approach
Pros
Cons
Conclusions
Adding Bootstrap
Choosing a native directives module
Installing ng2-bootstrap
Applying styles
Main navigation bar
Detecting the active route
Welcome View
Item Detail View
Display mode
Edit mode
Conclusions
Suggested topics
Summary
7. Authentication and Authorization
Do we really need these?
Authentication
Third-party authentication
Authorization
Third-party authorization
Proprietary or third-party?
Choosing an authentication mode
Installing AspNetCore.Identity
Adding the package
Updating the project classes
ApplicationDbContext.cs
ApplicationUser.cs
Startup.cs
DbSeeder.cs
Updating the database
Authentication methods
Sessions
Tokens
Signatures
Two-factor
Conclusions
Implementing JSON web token authentication
JWT provider
Private members
Static members
Constructor
Public methods
Private methods
Extension methods
Full source code
Adding the middleware to the pipeline
Angular 2 login form
Adding styles
Updating the root module file
UI and validation test
AuthService component
Updating the AppModule
Updating the LoginComponent
Login test
AuthHttp wrapper
Adding authorization rules
Adapting the client
Testing the client
Protecting the server
Retrieving the user ID
Authorization test
Suggested topics
Summary
8. Third-Party Authentication and External Providers
Introducing OpenID connect servers
Installing OpenIddict
Adding MyGet to the package sources
Installing the OpenIddict package
Updating ApplicationUser and ApplicationDbContext
Adding a new migration
Updating the DbSeeder
Moving literal values to appsettings.json
Configuring the Startup class
Updating the Web.Config rewrite rules
Seeding the database
External authentication providers
OAuth2 authorization flow
Facebook
Creating a Facebook App
Storing the keys in App settings
Adding the Facebook middleware
Adding the AccountsController
BaseController
AccountsController
Namespaces
Class declaration
Constructor
ExternalLogin
ExternalLoginCallBack
Logout
Updating the ItemsController
Configuring the client
Updating the LoginComponent
Updating the AuthService
Updating the AppComponent
Understanding zones
Testing it out
Google
Twitter
Elevated permissions request
Troubleshooting
Conclusions
Suggested topics
Summary
9. User Registration and Account Edit
User Registration
UserViewModel
AccountsController
Get
Add
E-mail confirmation
Update
Delete
User class
AuthService
UserEditComponent
Connecting the dots
Updating the root module
Implementing the route
Adding the Register link
Defining the styles
Updating the menu
Testing it out
Edit Account
Two routes, one component
Adapting the UserEditComponent
Updating the navigation menu
Adding styles
Final test
Conclusions
Suggested topics
Summary
10. Finalization and Deployment
Switching to SQL Server
Installing SQL Server 2016 Express
Installing SQL Server Management Studio
Configuring the database
Changing the authentication mode
Adding the OpenGameList database
Adding the OpenGameList login
Mapping the login to the database
Adding a SQL Server connection string
Creating an application settings file for production
Updating AppSettings
Updating external providers
Configuring the publishOptions
Checking the Startup class
Updating the launchSettings.json
Publishing our native web application
Creating a Publish profile
File System Publish profile
FTP Publish profile
Configuring IIS
Installing the ASP.NET Core module for IIS
Adding the website
Configuring the Application Pool
Firing up the engine
Troubleshooting
The Kestrel test
Suggested topics
Summary
← Prev
Back
Next →
← Prev
Back
Next →