ASP.NET Core 2 Fundamentals

Book description

Imagine the boost in business if you can build large, rich web applications with little code and built-in Windows authentication. With this book, you can gain skills to develop real-world applications with ASP.NET Core 2.

Key Features

  • Adopts the application-centric approach to explain core concepts
  • Covers industry-best practices to build flexible, robust applications
  • Shows how to enhance your applications by adding more functionalities

Book Description

The book sets the stage with an introduction to web applications and helps you build an understanding of the tried-and-true MVC architecture. You learn all about views, from what is the Razor view engine to tagging helpers. You gain insight into what models are, how to bind them, and how to migrate database using the correct model. As you get comfortable with the world of ASP.NET, you learn about validation and routing. You also learn the advanced concepts, such as designing Rest Buy (a RESTful shopping cart application), creating entities for it, and creating EF context and migrations. By the time you are done reading the book, you will be able to optimally use ASP.NET to develop, unit test, and deploy applications like a pro.

What you will learn

  • Work with basic programming constructs using the Razor view engine
  • Use flexibility and data compartmentalization of ViewModel
  • Build a custom route for ASP.NET MVC applications for SEO
  • Optimize applications with performance analysis and improvement steps
  • Improve application performance, security, and data access to optimize the overall development process
  • Deploy an ASP.NET MVC application in a non-Windows environment

Who this book is for

If you are looking to build web applications using ASP.NET Core or you want to become a pro in building web applications using the Microsoft technology, this is the ideal book for you. Prior exposure and understanding of C#, JavaScript, HTML, and CSS syntax is assumed.

Publisher resources

Download Example Code

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. ASP.NET Core 2 Fundamentals
  3. Packt Upsell
    1. Why subscribe?
  4. Contributors
    1. About the authors
    2. 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. Conventions used
    4. Get in touch
      1. Reviews
  6. Setting the Stage
    1. Introduction to Web Applications
      1. How Web Applications Work
        1. What is the HTTP Protocol?
        2. HTTP/2's Edge over HTTP/1.x
        3. Request-Response Pattern
        4. Stateless Nature of HTTP
        5. Advantages to HTTP
        6. Work with the Statelessness and the Request-Response Pattern
      2. Client Side and Server Side
      3. Programming Styles – RPC versus REST
      4. Working with HTTP Methods
        1. The GET Method
        2. The POST Method
        3. List of Important Methods
        4. Other Methods
      5. Activity: Working with the Request-Response Pattern
    2. Introduction to ASP.NET
      1. ASP.NET MVC
        1. The Model-View-Controller Pattern
      2. A File-Based Project
        1. Creating Your First Project
      3. Creating Your First Application
    3. Summary
  7. Controllers
    1. Role of the Controller in ASP.NET MVC Applications
      1. Ideal Flow of Data for a Layered Web Application
    2. Introduction to Routing
      1. Activity: Finding the Correct Method Invoked for a URL
    3. Installing the ASP.NET Core NuGet Package in Your Application
    4. Our First Controller
      1. IActionResult
      2. Activity: Implementing Your Own IActionResult
    5. Adding Views
    6. Adding Models
    7. Passing Data from the Controller to the View
    8. Filters
      1. Activity: Writing a Custom Filter
    9. Summary
    1. The View Engine and the Razor View Engine
      1. The Razor View Engine
        1. Programming in the Razor View Engine
        2. Variables in the Razor View
        3. Working with Razor View
        4. Programming Constructs in the Razor View
      2. Activity: Printing Prime Numbers from 1 to 100
    2. Layout
      1. Building our First Layout
        1. Creating _ViewStart.cshtml
        2. Creating _Layout.cshtml
        3. Adding a Page-Specific View
      2. Activity: Creating Another Layout and Changing the View to That Layout
    3. Generating HTML
      1. Generating HTML using a Simple Form
      2. HTML Helpers
        1. Generating a form using HTML Helpers
      3. Activity: Making Use of a Checkbox
    4. Partial View
      1. Calling a Partial View
      2. Activity: Working with Static Data
    5. View Components
      1. Creating a View Component
      2. Creating a ViewComponent Attribute
      3. Activity: Passing a String as Additional Data
    6. Tag Helpers
      1. Custom Tag Helpers
      2. Creating a Custom Tag Helper
      3. Activity: Replacing Email Tag Helpers
    7. Summary
  9. Models
    1. Introduction to Models
      1. Creating an ASP.NET Core Application
      2. Models Specific to a View Component
        1. ViewModels
      3. Data Flow with Respect to a Model
      4. Activity: Revising the Code to Show Discount in the Total
    2. Model Binding
    3. Entity Framework
      1. Creating Console Applications with Entity Framework
      2. Installing Entity Framework Core NuGet Package
        1. Using the NuGet Package Manager
      3. Installing Entity Framework Commands
        1. Creating Model Classes
        2. Creating the DbContext Class
      4. Creating a Migration
        1. How the SaveChanges Method Works
      5. Updating the Record
      6. Deleting the Record
      7. Activity: Controlling the Transaction Manually
    4. Using Entity Framework in ASP.NET MVC Applications
    5. Database Migration
    6. Summary
  10. Validation
    1. Introduction to Validation
    2. Client-Side and Server-Side Validation
    3. Server-Side Validation
      1. Updating ViewModels with the Data Annotation Attribute
      2. Updating the ViewModel to Display the Validation Error Message
      3. Updating the Controller Action Method to Verify the Model State
      4. Activity: Adding a New Validation Rule for Designation
    4. Client-Side Validation
      1. Performing Client-Side Validation
      2. Activity: Adding a New Validation Rule to a JavaScript Function
    5. Implementation
      1. Activity: Adding a New Validation Rule for Designation by Extending ValidationAttribute
    6. Summary
  11. Routing
    1. Convention-Based Routing
    2. Attribute-Based Routing
      1. Working on an Example of Attribute-Based Routing
    3. Route Attribute at the Controller Level
      1. Token Replacement in Route Templates
      2. Activity: Combining Route Templates that Begin with /
      3. Passing Routing Values in HTTP Action Verbs in the Controller
      4. Activity: Defining Two Actions with the Same Name with Different Verbs
    4. Route Constraints
      1. Activity: Creating an Attribute that Implements IActionConstraintFactory
    5. Summary
  12. Rest Buy
    1. Designing Rest Buy
      1. Features and Stories
      2. Layout and Pages
        1. Main Page
        2. Product Detail
        3. Checkout
        4. Checkout Success
        5. Previous Orders
      3. Defining our Domain and Model
      4. Creating a RestBuy Project
      5. Activity: Preparing Features and Stories for a Website
      6. Activity: Preparing Wireframe Diagrams for a Website
      7. Activity: Designing a Domain Model for a Website
    2. Creating the Entities
    3. Create EF Context and Migrations
      1. Create migrations
      2. Activity: Adding a Supplier Entity that Denotes the Supplier of a Product
    4. Summary
  13. Adding Features, Testing, and Deployment
    1. Adding the Registration Feature
      1. Sign In and Sign Out Mechanism
      2. Creating the Application Layer
      3. Performing Implementations in the Infrastructure Project
      4. Defining our ViewModel for Registration
      5. Defining our Controllers
      6. Creating the Post-Registration Landing Page
      7. Creating a Query for the Registration Service
      8. Validating the Registration
    2. Creating a Unit Test
      1. Writing a Unit Test
      2. Running the Unit Test
      3. Activity: Writing a Unit Test for Deletion
    3. Upgrading Our Project to Bootstrap 4
      1. Activity: Adding a EULA Agreement
    4. Deploying RestBuy to Azure
      1. Signing up to Microsoft Azure
      2. Prerequisites to Azure Deployment
      3. Deploying Rest Buy to Azure
    5. Summary
  14. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: ASP.NET Core 2 Fundamentals
  • Author(s): Onur Gumus, Mugilan T. S. Ragupathi
  • Release date: August 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789538915