Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
ASP.NET Core: Cloud-ready, Enterprise Web Application Development
ASP.NET Core: Cloud-ready, Enterprise Web Application Development
Credits
Preface
What this learning path covers
What you need for this learning path
Who this learning path is for
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Module 1
1. Introduction to ASP.NET Core
How web applications work
So what is an HTTP protocol?
Request-response pattern
Stateless nature of HTTP
Client-side and server-side
HTTP methods
GET method
POST method
What is ASP.NET?
ASP.NET Web Forms
ASP.NET Web Pages
ASP.NET MVC
Features of ASP.NET MVC
Convention over configuration
Separation of concerns
Control over the generated HTML
Better support for unit testing
ASP.NET 5
Features of ASP.NET 5
Summary
2. Setting Up the Environment
Purpose of IDE
Visual Studio offerings
System requirements
Visual Studio Community 2015
Visual Studio Professional
Visual Studio Enterprise
Visual Studio Test Professional
Installing Visual Studio Community
Installing ASP.NET 5
Project structure in ASP.NET 5 application
File-based project
Support for full .NET and .NET core
The Project.json package
Controllers
Models
Views
Migrations
The wwwroot folder
Other files
Summary
3. Controllers
Role of the Controller in ASP.NET MVC applications
Introduction to routing
Creating ASP.NET 5 application
Installing the ASP.NET Core NuGet package in your application
Our first Controller
IActionResult
Adding Views
Adding Models
Passing data from Controller to View
Filters
Authorization filters
Resource filters
Action filters
Exception filters
Result filters
Summary
4. Views
The View engine and the Razor View engine
Razor View engine
Programming in Razor View engine
Variables in Razor View
The for loop
The while loop
The foreach loop
The if condition
Layout
Creating _ViewStart.cshtml
Creating _Layout.cshtml
Adding a page-specific View
Generating HTML
HTML Helpers
Partial View
Calling the Partial View
View components
Creating a View component
Tag Helpers
Creating custom Tag Helpers
Summary
5. Models
Models
Models specific to a View component
Note on ViewModels
Data flow with respect to a Model
Model binding
The Entity Framework
The Entity Framework is independent of ASP.NET MVC
Creating console applications with the Entity Framework
Installing the Entity Framework 7 NuGet package
Using the NuGet Package Manager
Using the Package Manager Console
Installing Entity Framework commands
Creating Model classes
Creating the DbContext class
Create a migration
How the SaveChanges method works
Updating the record
Deleting the record
Using the Entity Framework in ASP.NET MVC applications
Database migration
Summary
6. Validation
Client-side and server-side validation
Server-side validation
Updating View models with the Data Annotation attribute
Updating the View model to display the validation error message
Updating the controller action method to verify the model state
Client-side validation
Implementation
Summary
7. Routing
Convention-based routing
Example 1
Example 2
Example 3
Example 4
Attribute-based routing
Route attribute at the controller level
Passing routing values in HTTP action verbs in the Controller
Route Constraints
Summary
8. Beautifying ASP.NET MVC Applications with Bootstrap
Knowing HTML and CSS
Bootstrap
Bootstrap Grid system
Forms
Inline forms
Horizontal forms
Table CSS classes
Striped tables
Hover tables
Bordered tables
Contextual classes in table
Buttons
Button sizes
Contextual colors
Using Bootstrap in your ASP.NET MVC application
Installing with Bower
HTML doctype
Summary
9. Deployment of ASP.NET Core Application
The project.json file
The dependencies node
The frameworks node
Microsoft Azure
Signing up to Microsoft Azure
Prerequisites to Azure deployment
Deploying the ASP.NET Core application in Azure
Deploying the ASP.NET Core web application in the Linux environment
Creating a Linux machine
Installing the PuTTY client
Installing of .NET Core in a Linux machine
Creating a new ASP.NET 5 project
Configuring the Nginx server
Summary
10. Building HTTP-based Web Services Using ASP.NET Web API
HTTP basics
HTTP verbs
GET method
PUT method
POST method
DELETE method
Fiddler tool
Dependency Injection
Delete method
The Web API method for deleting a resource
Web Repository layer code for deleting the employee data
Summary
11. Improving Performance of an ASP.NET Core Application
The UI layer
Reducing the number of HTTP requests
Using GZip compression
Using the Content Delivery Network (CDN)
Using JavaScript wherever possible
Using CSS stylesheets
Minification of JavaScript and CSS files and their combination
The caching process
Client-side caching
Response caching
The web/application layer
No business logic in Views
Using asynchronous logging
The DB layer
Understanding the queries generated by the ORM
Using classic ADO.NET if you really want to
Return only the required data
Fine tuning the indices
Using the correct column type and size for your database columns
Avoiding correlated subqueries
Generic performance improvement tips
Avoiding the Response.Redirect method
Using string builder
Summary
12. ASP.NET Core Identity
Authentication
Authorization
Adding the relevant dependencies to the project.json file
Adding ApplicationUser and ApplicationDbContext classes
Configuring the application to use Identity
Creating ViewModels
Creating Controllers and associated action methods
Creating Views
E-mail and SMS services
Securing an action method in a Controller
Summary
2. Module 2
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
3. Module 3
1. Why Performance Is a Feature
Performance as a feature
Common classes of performance problems
Language considerations
Types of performance problems
When performance matters
Slower is sometimes better
Why issues are missed
Measuring
The benefits of planning ahead
Understanding hardware
Storage access speeds
Scaling approach changes
Tools and costs
Tools
Looking at some alternative tools
The new .NET
Summary
2. Measuring Performance Bottlenecks
Tools
SQL
SQL Server Profiler
Executing a simple query
MiniProfiler
Application profiling
Glimpse
Using Glimpse
IDE
Monitoring HTTP
Browsers
Chrome
Firefox
Fiddler
Network
Microsoft Message Analyzer
Wireshark
Roll your own
Science
Repeatability
Only change one thing
Summary
3. Fixing Common Performance Problems
Latency
Asynchronous operations
Simple asynchronous tools
Background queuing
Hangfire
Select N+1 problems
Efficient paging
Static site generators
Pragmatic solutions with hardware
A desktop example
Web applications
Oversized images
Image resolution
Image format
Summary
4. Addressing Network Performance
Internet protocols
TCP/IP
Slow-start
HTTP
Headers
HTTP methods
Status codes
Encryption
Key exchange
Delay diagnostics
Performance tweaks
HTTP/2
WebSockets
Compression
Lossless compression algorithms
Bundling and minification
Bundling
Minification
Changes in ASP.NET Core
Image optimization
PNG
JPEG
Other image formats
Resizing images
Caching
Browser
Server
Proxy servers between you and your users
CDNs
Summary
5. Optimizing I/O Performance
Input/output
Categories of I/O
Disks
Virtual file systems
Databases
APIs
Network diagnostics tools
Ping
Tracert
Nslookup
Build your own
Solutions
Batching API requests
Efficient DB operations
Database tuning
Reporting
Aggregates
Sampling
Inserting data
GUIDs
Advanced DB topics
Simulation and testing
Summary
6. Understanding Code Execution and Asynchronous Operations
Getting started with the core projects
.NET Core
ASP.NET Core
Kestrel
Data structures
Lists
Dictionaries
Collection benchmarks
Bloom filters
Hashing and checksums
Hashing benchmarks
Serialization
SIMD CPU instructions
Parallel programming
Task Parallel Library
Parallel LINQ
Parallel benchmarking
Parallel programming limitations
Practices to avoid
Reflection
Regular expressions
String concatenation in tight loops
Dynamic typing
Synchronous operations
Exceptions
Summary
7. Learning Caching and Message Queuing
Why caching is hard
Web caching
Caching background
HTTP headers
Cache busting
Service workers
Service worker example
Web and proxy servers
IIS
Varnish
Working with a content delivery network
When not to cache
Application layer caching
Redis
Database result set caching
Message queuing
Coffee shop analogy
Message queuing styles
Common messaging patterns
Unicast
Pub/sub
RabbitMQ
Queuing frameworks and libraries
Summary
8. The Downsides of Performance-Enhancing Tools
Managing complexity
Understanding complexity
Complexity reduction
Frameworks
Architecture
Monolith versus microservices
Architecture comparison
Refactoring
A culture of high performance
A blameless culture
Intellectual dishonesty
Slow down to go faster
From the ground up
Shared values
The price of performance
Distributed debugging
Logging
Error logging
Application Insights
Integrated logging
Centralized logging
Statistics
Managing stale caches
Summary
9. Monitoring Performance Regressions
Profiling and measurement
Testing
Automated testing
Continuous integration
Slow testing
Fixing performance regressions
Load testing
Realism
Realistic environments
Realistic workloads
Feature switching
Experimenting for science
A/B testing
User interface testing
Web UI testing tools
Automating UI performance tests
Staying alert
DevOps
DevOps tooling
Provisioning
Monitoring
Hosting
Summary
10. The Way Ahead
Reviewing what we learned
Further reading
Going native
Processor architecture
Hardware is hard
Machine learning
Big data and MapReduce
Orleans
Custom transports
Advanced hashing
Library and framework support
The future
Summary
Bibliography
← Prev
Back
Next →
← Prev
Back
Next →