O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hands-On Full-Stack Web Development with ASP.NET Core

Book Description

Become a full-stack developer by learning popular Microsoft technologies and platforms such as .NET Core, ASP.NET Core, Entity Framework, and Azure

Key Features

  • Bring static typing to web development with features compatible in TypeScript 3
  • Implement a slim marketplace single page application (SPA) in Angular, React, and Vue
  • Modernize your web apps with Microsoft Azure, Visual Studio, and Git

Book Description

Today, full-stack development is the name of the game. Developers who can build complete solutions, including both backend and frontend products, are in great demand in the industry, hence being able to do so a desirable skill. However, embarking on the path to becoming a modern full-stack developer can be overwhelmingly difficult, so the key purpose of this book is to simplify and ease the process.

This comprehensive guide will take you through the journey of becoming a full-stack developer in the realm of the web and .NET. It begins by implementing data-oriented RESTful APIs, leveraging ASP.NET Core and Entity Framework. Afterward, it describes the web development field, including its history and future horizons. Then, you'll build webbased Single-Page Applications (SPAs) by learning about numerous popular technologies, namely TypeScript, Angular, React, and Vue. After that, you'll learn about additional related concerns involving deployment, hosting, and monitoring by leveraging the cloud; specifically, Azure.

By the end of this book, you'll be able to build, deploy, and monitor cloud-based, data-oriented, RESTful APIs, as well as modern web apps, using the most popular frameworks and technologies.

What you will learn

  • Build RESTful APIs in C# with ASP.NET Core, web APIs, and Entity Framework
  • See the history and future horizons of the web development field
  • Bring static-typing to web apps using TypeScript
  • Build web applications using Angular, React, and Vue
  • Deploy your application to the cloud
  • Write web applications that scale, can adapt to changes, and are easy to maintain
  • Discover best practices and real-world tips and tricks
  • Secure your backend server with Authentication and Authorization using OAuth 2.0

Who this book is for

This book is for developers who are keen on strengthening their skills in the field of cloud-based full-stack web development. You need basic knowledge of web-related pillars, including HTML, CSS, and JavaScript, as well as C# and REST.

This book targets novice developers in the realm of Web development and ASP.NET who desire to advance to modern Web and ASP.NET Core development and leverage the Cloud to manage and bring everything together.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Full-Stack Web Development with ASP.NET Core
  3. PacktPub.com
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Becoming a Full-Stack .NET Developer
    1. The full-stack developer
      1. Full-stack development
    2. Backend fundamentals
      1. Hypertext Transfer Protocol 
        1. HTTP is a stateless protocol
        2. HTTP/2
      2. Representational State Transfer
      3. ASP.NET Core
    3. Frontend fundamentals
      1.  Hypertext Markup Language 
      2. CSS
      3. JavaScript
      4. TypeScript
    4. JavaScript frontend frameworks
      1. Angular
      2. React
      3. Vue.js
    5. Summary
  7. Setting Up Your Development Environment
    1. Visual Studio
      1. Installing Visual Studio Community
    2. Node.js and npm
      1. Installing Node.js
    3. TypeScript
      1. Installing TypeScript
    4. Google Chrome
    5. Fiddler
      1. Installing Fiddler
    6. Summary
  8. Creating a Web Application with ASP.NET Core
    1. ASP.NET Core overview
      1. .NET Core
      2. Open source
      3. Lightweight and fast
      4. Modular
      5. Host anywhere
    2. Creating an ASP.NET Core application
      1. Default files in an ASP.NET Core project
      2. Predefined project templates
    3. The Startup class
      1. Code execution order
      2. Different startups for different environments
      3. Changing the Startup class name
    4. Serving static files
      1. The content root and web root folders
      2. Setting the server to serve static files
      3. Serving default documents
      4. Configuring the available MIME types
    5. Getting familiar with the ASP.NET Core MVC framework
      1. The MVC pattern
      2. MVC in SPAs
      3. Adding MVC to ASP.NET Core
      4. Controllers
      5. Views
        1. View files and their location
        2. Creating a view
      6. Routing
        1. Adding routes
          1. Adding routes via UseMvc
          2. Adding routes via route attributes
        2. Routing in SPAs
    6. Summary
  9. Building REST APIs with ASP.NET Core Web API
    1. Overview — REST APIs with ASP.NET Core API
      1. Creating a simple API 
    2. Inspecting your APIs using Fiddler and Postman
      1. Fiddler
      2. Postman
    3. Routing
      1. Conventional routing
        1. Defining a new route template
      2. Attribute-based routing
        1. Parameterizing the route template
          1. Default values
          2. Constraints
    4. The model
      1. Model binding
        1. Query strings
        2. Message body
        3. Header values
        4. Model validation
    5. Generating a response of different types
      1. Explicit return type
      2. IActionResult and ActionResult<T>
      3. Asynchronous actions
      4. Controller response helper methods
    6. Summary
  10. Persisting Data with Entity Framework
    1. Installing Entity Framework Core 
    2. Creating your data model
      1. Defining the entities
      2. The DbContext
        1. Configuring the model mapping
        2. Configuring the database connection with DbContextOptions<TContext>
    3. Creating a database with EF Core migrations
      1. Creating a new migration
      2. Adding automatic migrations
        1. Connecting to the database 
        2. Adding seed data
    4. Saving data
      1. Updating and deleting objects
    5. Querying data
      1. Loading related entities
      2. Creating conditional queries with the IQueryable deferred execution
    6. Mapping the API results to DTOs
      1. Mapping entities to DTOs with AutoMapper
    7. Summary
  11. Securing the Backend Server
    1. Authenticating and authorizing application users
      1. Adding identity management entities to your data model
      2. Enabling the identity infrastructure 
        1. Enabling token-based authentication with JSON Web Token
      3. The authentication and authorization flow
      4. Creating a user registration API
      5. Implementing the login functionality and generating a JWT
        1. Adding user claims
      6. Configuring your backend to always require authentication  
        1. Configuring an action to allow anonymous access
    2. Controlling access to APIs with authorization
      1. Adding claims that can be used for authorization
        1. Authorizing users by their role
        2. Creating an authorization policy
    3. Enabling Cross-Origin Resource Sharing
    4. Summary
  12. Troubleshooting and Debugging
    1. Adding logging to your application
      1. Writing a log message from the controller
        1. Filtering log messages
      2. Log providers
        1. Provider-specific configuration and filters
      3. Enabling diagnostics with Application Insights
    2. Responding gracefully in the event of errors and exceptions
      1. Adding a correlation identifier to responses
      2. The developer exception page
      3. Adding a global exception handler
    3. Making your APIs discoverable and self-documenting with the OpenAPI standard (Swagger)
      1. Generating a Swagger file from the ASP.NET Core application
      2. Adding the Swagger UI to your application
        1. Sending a request through the Swagger UI 
      3. Generating client code from a Swagger file
        1. Swagger editor
    4. Summary
  13. Getting Started with Frontend Web Development
    1. Getting started with frontend web development
      1. HTML
      2. CSS
      3. JavaScript
      4. Notable progress and future development
        1. Web components
        2. WebAssembly
    2. The Everyday Market app
      1. Homepage with product listings
      2. Product page
      3. New product page
    3. jQuery
      1. Everyday Market homepage using jQuery
        1. Initial layout
        2. REST API access
        3. Menu item template
        4. Category menu items query
        5. Product item template
        6. Product cards query
        7. Busy indicator
    4. Summary
  14. Getting Started with TypeScript
    1. TypeScript
    2. The TypeScript compiler
    3. Types
      1. Basic types
      2. Arrays
      3. Enums
      4. Objects
      5. Functions
      6. Type inference
      7. Type casting
      8. Type aliasing
    4. Interfaces
      1. Extending interfaces
    5. Classes
      1. Access modifiers
      2. Members
      3. Class inheritance and interface implementation
    6. Modules
    7. Decorators
    8. Summary
    9. Further reading
  15. App Development with Angular
    1. Angular overview
      1. Building blocks
    2. Angular CLI
      1. Setup and common commands
        1. Linting code
        2. Running tests
        3. Running the project
    3. Key app parts
    4. Modules
    5. Components
      1. Header component
      2. Global styles
      3. Assets
      4. Category-menu-item component
      5. category-menu component
      6. products-page component
    6. Data binding
      1. Interpolation binding
      2. Property binding
      3. Event binding
      4. Two-way binding
    7. Component interaction
      1. Input
        1. ngFor
      2. Output
    8. Injectable services
    9. HTTP
    10. Busy indicator
      1. ngIf
    11. Distribution
      1. Environments
    12. Summary
  16. Implementing Routing and Forms
    1. Client-side routing
    2. Using Angular Router
    3. Implementing a routed page
    4. Implementing template-driven forms in Angular
      1. Using Angular's ngModel directive
      2. Implementing form validation
        1. Element references
    5. Summary
  17. App Development with React
    1. React overview
      1. Building blocks
    2. Creating a React app
      1. Key app parts
    3. Components
      1. Render function
    4. JSX
      1. Using JSX
    5. Header component
    6. Props
    7. State
      1. setState
    8. Stateless functional components
    9. CategoryMenu
    10. List rendering
    11. Product listing
    12. Busy indicator
    13. Conditional rendering
    14. Summary
  18. App Development with Vue
    1. Vue.js overview
      1. Building blocks
    2. Vue CLI
      1. Key app parts
    3. Components
      1. Single file components
    4. Header component
      1. Global styles
      2. Assets
    5. Data binding and component interaction
      1. Component definition object
      2. Props
      3. Interpolation binding
      4. Property binding
      5. Data
      6. Methods
      7. Events
      8. Computed
    6. The category menu
    7. List rendering
    8. Product listing
    9. Busy indicator
    10. Conditional rendering
    11. Summary
  19. Moving Your Solution to the Cloud
    1. What is cloud computing?
      1. Virtualization and automation
      2. Cloud service models
    2. Working with Microsoft Azure 
      1. Creating a Microsoft Azure account
    3. Getting familiar with the portal and with the command line
      1. The Azure portal
      2. Azure portal blades
      3. Using the Azure CLI
    4. The Azure account and resources model
      1. Azure Resource Manager
        1. Resource groups
        2. ARM templates
      2. Pricing and billing
    5. Summary
  20. Deploying to Microsoft Azure
    1. Creating a production environment with Azure App Service
      1. App Service plan
      2. Creating your App Service 
      3. Linking a SQL server database to the application 
        1. Choosing an Azure SQL pricing tier
    2. Deploying the GiveNTake backend service from Visual Studio
    3. Creating an automated build and release pipeline in Azure DevOps 
      1. Creating a build pipeline
      2. Creating a release pipeline that will deploy to Azure
        1. Configure the release pipeline artifact
        2. Configure the release pipeline stage
    4. Deploying the GiveNTake frontend to Azure App Service
      1. Configuring Azure App Service to work with an Angular application
      2. Creating a build pipeline for the Angular app
      3. Creating a release pipeline for the Angular app
    5. Summary
  21. Taking Advantage of Cloud Services
    1. Scaling your service
      1. Scaling up your App Service 
      2. Scaling out your App Service 
        1. Autoscaling
    2. Cloud Diagnostics with Application Insights
      1. Connecting Azure Application Insights to your App Service
      2. Connecting the ASP.NET Core logger to Azure Application Insights
        1. Setting the Instrumentation Key in Application settings
      3. Analyzing Application Insights telemetry
        1. End-to-end transaction analysis 
        2. Advanced querying and visualizing with Analytics
        3. Application map
    3. Testing in production with Deployment slots
      1. Deploying to a Deployment slot
        1. Swapping between Deployment slots
      2. Testing in production
    4. Summary
  22. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think