The ASP.Net Core 2.0 Framework is designed to meet the needs of today's web developers. It provides better control, support for test-driven development, and cleaner code. Moreover, it's lightweight and allows you to run apps on Windows, OSX, and Linux, making it the most popular web framework with modern day developers.
This book follows a unique approach to web development, using real-world examples that guide you through problems with ASP.NET Core 2.0 web applications. It covers VS2017 and ASP.NET Core 2.0-specific changes, and provides general MVC development recipes. It explores setting up .NET Core, Visual Studio 2017, Node.js modules, and NuGet. Next, it shows you how to work with Inversion of Control data pattern and caching. We explore everyday ASP.NET Core MVC 2.0 patterns and go beyond ASP.NET Core MVC 2.0 , into troubleshooting. Finally, we will lead you through migrating, hosting, and deploying your code.
By the end of this book, you'll not only have explored every aspect of ASP.NET Core 2.0, you'll also have a reference you can keep coming back to whenever you need to get the job done.
This book is for developers who want to learn to build web applications and make a career building web applications using ASP.NET Core.
If you're new to programming, this book will introduce you to the patterns and concepts used to build modern web applications.
This book is also for those who are working on other web frameworks and want to learn more about ASP.NET Core.
You'll learn how to build a web app from scratch; this book will give you a starting point so you can learn more advanced topics.
Chapter 1, Cross-Platform with .NET Core, dives deep into what .NET Core is, what its core components are, and creating ASP.NET Core web projects using the .NET Core CLI.
Chapter 2, Visual Studio 2017, C# 6, IDEs, and Roslyn, covers the use of Visual Studio 2017, Visual Studio Code, and Atom as C# editors. Also, we'll investigate the new features that come with C# 6 and use Roslyn compiler as a service.
Chapter 3, Working with NPM, Frontend Package Managers, and Task Runners, covers using and creating npm modules and using Bower, Grunt, Gulp, and Yeoman.
Chapter 4, Reusing Code with NuGet, guides you though manage NuGet packages, creating new NuGet packages, using previously created packages, and creating a new NuGet repository to privately list NuGet packages.
Chapter 5, SOLID Principles, Inversion of Control, and Dependency Injection, covers all SOLID principles, plus the inversion of Ccontrol and dependency injection libraries that come with ASP.NET Core and seperate NuGet packages.
Chapter 6, Data Access - Entity Framework with Repository, SQL Server, and Stored Procedures, covers implementing the repository pattern using Entity Framework Core. During implementation, we'll cover the IoC life cycle. Also, we'll investigate different providers of Entity Framework Core.
Chapter 7, Data Access with Micro ORMs, NoSQL, and Azure, covers creating DataAccessLayer with several libraries, such as Dapper and OrmLite. Also, we'll investigate MongoDB, Azure table storage, Azure blob storage, and SQL on Azure.
Chapter 8, Cache and Session - Distributed, Server, and Client, covers caching with several providers, such as InMemory Data Caching, Response Caching, Session Caching, and Distributed Caching. We'll use Redis on both on-premises and Azure.
Chapter 9, Routing, discusses the different aspects of ASP.NET Routing mechanisms, Route Constraints, and SEO-friendly routing.
Chapter 10, ASP.NET Core MVC, covers ActionResult types, creating and using POCO controllers, and managing Exceptions.
Chapter 11, Web API, discusses managing content-negotiation, handling cross-domain requests, auto-documenting controllers and actions using Swagger, and testing actions.
Chapter 12, Filters, covers how to create, manage, and use Global Filters for injecting tasks before and after the execution of actions, such as logging, caching, controlling authentication, and authorization.
Chapter 13, Views, Models, and ViewModels, covers creating and using ViewModels, and understanding and using the ModelBinding mechanism and ValueProviders.
Chapter 14, Razor and Views, talks about views, partial views, areas, HTML helpers, and dependency injection into views.
Chapter 15, TagHelpers and ViewComponents, dives deep into using Environment, Script, Form, and Link TagHelpers. We'll also create reusable ViewComponents.
Chapter 16, OWIN and Middlewares, describes OWIN and Katana, the new ASP.NET Core pipelines and middleware, along with creating and using ASP.NET Core middleware.
Chapter 17, Security, covers Authentication and Authorization mechanisms, managing Identity, and securing data with ASP.NET Core.
Chapter 18, Frontend Development, covers how to use Bootstrap classes, write maintainable and clean JavaScript code, and debug it. We will see what TypeScript is and write unit tests for JavaScript code.
Chapter 19, Deployment and Hosting, covers hosting ASP.NET Core web applications using IIS, Azure, and Docker. We'll also host ASP.NET web applications on Linux, Windows, and Mac environments using Kestrel.
- It's beneficial to have some web backend or frontend programming experience.
- You'll need Visual Studio 2017, Visual Studio Code, Atom, SQL Server Management Studio, and a modern web browser installed. Don't worry, we'll guide you on how to install them when needed.
- You'll need an active Azure subscription. The Microsoft Azure platform offers free trial accounts at http://www.azure.com
You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
- Log in or register at www.packtpub.com.
- Select the
SUPPORT
tab. - Click on
Code Downloads & Errata
. - Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
- WinRAR/7-Zip for Windows
- Zipeg/iZip/UnRarX for Mac
- 7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/ASP.NET-MVC-Core-2.0-Cookbook. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/ASP.NETMVCCore2.0Cookbook_ColorImages.pdf.
There are a number of text conventions used throughout this book.
CodeInText
: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Run dotnet new mvc
from the command line. This command will create a new ASP.NET Core MVC project with the same name as the containing folder."
A block of code is set as follows:
public class Person { public class Name {get;set;} public Person(){ Name = "Stephane"; } }
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
public class Person
{
public class Name {get;set;}
public Person(){
Name = "Stephane";
}
}
Any command-line input or output is written as follows:
$ apt-get install nautilus-open-terminal
$ killall nautilus && nautilus
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select the Subscription
."
In this book, you will find several headings that appear frequently (Getting ready, How to do it..., How it works..., There's more..., and See also).
To give clear instructions on how to complete a recipe, use these sections as follows:
This section tells you what to expect in the recipe and describes how to set up any software or any preliminary settings required for the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make you more knowledgeable about the recipe.
Feedback from our readers is always welcome.
General feedback: Email [email protected]
and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected]
.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected]
with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packtpub.com.