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

.NET Core 2.0 By Example

Book Description

Build cross-platform solutions with .NET Core 2.0 through real-life scenarios

About This Book

  • Bridges the gap between learning and doing and improves your software development skills
  • Covers the best practices of .NET development to improve your productivity
  • Example-based approach to get you started quickly with software programming

Who This Book Is For

If you are a developer or architect and want to learn how to build cross-platform solutions using Microsoft .NET Core, this book is for you. It is assumed that you have some knowledge of the .NET Framework, OOP, and C# (or a similar programming language).

What You Will Learn

  • Build cross-platform applications with ASP.NET Core 2.0 and its tools
  • Integrate, host, and deploy web apps with the cloud (Microsoft Azure)
  • Leverage the ncurses native library to extend console capabilities in .NET Core on Linux and interop with native coden .NET Core on Linux and learn how to interop with existing native code
  • Reuse existing .NET Framework and Mono assemblies from .NET Core 2.0 applications
  • Develop real-time web applications using ASP.NET Core
  • Learn the differences between SOA and microservices and get started with microservice development using ASP.NET Core 2.0
  • Walk through functional programming with F# and .NET Core from scratch

In Detail

With the rise in the number of tools and technologies available today, developers and architects are always exploring ways to create better and smarter solutions. Before, the differences between target platforms was a major roadblock, but that's not the case now. .NET Core 2.0 By Example will take you on an exciting journey to building better software.

This book provides fresh and relevant content to .NET Core 2.0 in a succinct format that's enjoyable to read. It also delivers concepts, along with the implications, design decisions, and potential pitfalls you might face when targeting Linux and Windows systems, in a logical and simple way.

With the .NET framework at its center, the book comprises of five varied projects: a multiplayer Tic-tac-toe game; a real-time chat application, Let'sChat; a chatbot; a microservice-based buying-selling application; and a movie booking application. You will start each chapter with a high-level overview of the content, followed by the above example applications described in detail. By the end of each chapter, you will not only be proficient with the concepts, but you'll also have created a tangible component in the application.

By the end of the book, you will have built five solid projects using all the tools and support provided by the .NET Core 2.0 framework.

Style and approach

This book takes a concise yet comprehensive project-based approach to teaching the tricks and tools of .NET Core 2.0.

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. .NET Core 2.0 By Example
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the authors
    2. About the reviewer
    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. Getting Started
    1. Downloading required tools for Windows and Linux
      1. Downloads for Windows
      2. Downloads for Linux
    2. Installing .NET Core 2.0 and tools (Windows)
      1. Installing Visual Studio 2017 version 15.3
      2. Installing Visual Studio Code
    3. Setting up an Ubuntu Linux VM
      1. Ubuntu setup using Hyper-V
    4. Installing .NET Core 2.0 and tools (Linux)
    5. Creating simple running code
      1. Creating an application in Windows through Visual Studio 2017 version 15.3
      2. Creating application in Windows through Visual Studio Code
    6. F# primer
      1. F# keywords
      2. Comments
      3. Data types
      4. Variable declaration
      5. Operators 
        1. Arithmetic operators
        2. Comparison operators
        3. Boolean operators
        4. Bitwise operators
      6. Decision-making statements
        1. if statements
        2. Loop statements
      7. F# functions
        1. Calling a function
          1. File sequence
        2. Basic input/output syntax
    7. Summary
  7. Native Libraries in .NET Core
    1. Introduction to ncurses
    2. Interop with existing native and Mono libraries
      1. Platform Invoke (P/Invoke) 
        1. DLLImport attribute
        2. Interop with existing native libraries with example
        3. When not to use P/Invoke
    3. Building a sample native library (C++)
    4. A sample application to implement new library and ncurses
    5. Summary
  8. Building Our First .NET Core Game – Tic-Tac-Toe
    1. Anatomy of an ASP.NET Core 2.0 application 
    2. Tic-Tac-Toe 
      1. Requirement specifications
    3. Designing the game
    4. SignalR
      1. SignalR transport mechanisms
      2. SignalR Core
    5. Solution
      1. Project setup
      2. Coding the game
      3. Game demo
    6. Summary
  9. Let's Chat Web Application
    1. Let's Chat web app requirement specifications
    2. Let's Chat web app – high-level design
    3. Project setup
      1. Authentication
        1. Windows authentication
        2. Forms authentication
        3. Token-based authentication
      2. Authorization
        1. Simple authorization
        2. Role-based authorization
        3. Claims-based authorization
      3. Middleware
      4. Dependency Injection
      5. How do you write custom middleware?
      6. Configuration
      7. Logging
    4. Summary
  10. Developing the Let's Chat Web Application
    1. ASP.NET Core 2.0 fundamentals
      1. Quick lap around MVC
        1. Routing
        2. Model binding
        3. Validation
        4. Filters
        5. Controllers
        6. Error handling
    2. Implementing authentication through Facebook
    3. Summary
  11. Testing and Deploying – The Let's Chat Web Application
    1. Chat hub module
      1. Razor primer
      2. Tag Helpers
      3. Views
      4. Razor pages
      5. Coding the Chat hub module
    2. Testing overview
      1. Unit testing
      2. Testing using xUnit
      3. Live Unit Testing
    3. Introduction to containers
      1. Docker
    4. Bot 101
    5. Summary
  12. To the Cloud
    1. Introduction to the cloud
    2. Types of cloud
    3. Getting started with Azure
      1. Creating a VM in Azure
      2. Automating using PowerShell
      3. Publishing a web app in Azure
        1. Azure App Services
        2. Publishing the web app
        3. Publishing profiles
      4. App Service features 
        1. DEPLOYMENT
        2. SETTINGS
        3. DEVELOPMENT TOOLS
        4. API
        5. MONITORING
        6. SUPPORT + TROUBLESHOOTING
      5. Cloud storage
    4. Summary
  13. Movie Booking Web App
    1. Introducing Entity Framework
    2. Presenting Entity Framework Core
    3. Getting started with Entity Framework Core
    4. Movie booking app requirements
    5. Designing the movie booking app
    6. Coding the movie booking app
    7. Deploying the movie booking app
    8. Monitoring the movie booking app
      1. Application Insights
    9. Summary
  14. Microservices with .NET Core
    1. Introduction to microservices
      1. A traditional service
      2. Microservices
    2. Handy things to know
      1. General tips
      2. Performance tips
      3. Azure tips
    3. Introducing Blazor
    4. What's coming in .NET Core 2.1
    5. Summary
  15. Functional Programming with F#
    1. Introduction to functional programming
      1. Functional programming features
        1. Higher-order functions (HOF)
        2. Purity
        3. Recursion
        4. Currying
        5. Closure
        6. Function composition
    2. Introduction to F#
      1. Basics of classes
        1. Constructor of a class
          1. A let and do binding
          2. Generic type parameters
      2. Properties
        1. Static and instance properties
        2. Abstract properties
      3. Inheritance and casts
        1. Virtual methods and overrides
        2. Constructors and inheritance
      4. Functions and lambda expressions
      5. Handling data – tuples, lists, record types, and data manipulation
        1. List
        2. Record type
      6. Object-oriented programming in F#
      7. Exception handling
    3. Data access layer with F#
      1. CSV, HTML, JSON, and XML data
        1. Providers
        2. Data access tools
      2. SQL data access
      3. Web data access
    4. Querying SQL vNext with F#
    5. Summary
  16. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think