inside front cover
ASP.NET Core in Action
Second Edition
Andrew Lock
To comment go to liveBook
Manning
Shelter Island
For more information on this and other Manning titles go to
www.manning.com
Copyright
For online information and ordering of these and other Manning books, please visit www.manning.com. The publisher offers discounts on these books when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964
Email: orders@manning.com
2021 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine.
| Manning Publications Co. 20 Baldwin Road Technical PO Box 761 Shelter Island, NY 11964 |
Development editor: | Marina Michaels |
Technical development editor: | Mark Elston |
Review editor: | Mihaela Batini |
Production editor: | Deirdre S. Hiam |
Copy editor: | Andy Carroll |
Proofreader: | Jason Everett |
Technical proofreader: | Tanya Wilke |
Typesetter: | Dennis Dalinnik |
Cover designer: | Marija Tudor |
ISBN: 9781617298301
front matter
preface
ASP.NET Core 5.0 was released in 2020, more than four years after the release of ASP.NET Core 1.0. But ASP.NET also has a long history prior to ASP.NET Core. That history provided the basis and impetus for the development of ASP.NET Core.
Microsoft released the first version of ASP.NET in 2002 as part of the original .NET Framework 1.0. Since then, its been through multiple iterations, with each version bringing added features and extensibility. However, each iteration has been built on top of the .NET Framework, and so comes preinstalled in all versions of Windows.
This brings mixed blessingson the one hand, the ASP.NET 4.x framework today is a reliable, battle-tested platform for building modern applications on Windows. On the other hand, it is also limited by this reliancechanges to the underlying .NET Framework are far-reaching and so consequently slow to roll out, and it fundamentally excludes the many developers building and deploying to Linux or macOS.
When I first began looking into ASP.NET Core, I was one of those developers. A Windows user at heart, I was issued a Mac by my employer and so was stuck working in a virtual machine all day. ASP.NET Core promised to change all that, allowing me to develop natively on both my Windows machine and my Mac.
I was relatively late to the party in many respects, only taking an active interest just before the time of the RC2 release of ASP.NET Core. By that point there had already been eight beta releases, many of which contained significant breaking changes. By not diving in fully until RC2, I was spared the pain of dodgy tooling and changing APIs.
What I saw at that point really impressed me. ASP.NET Core let developers leverage their existing knowledge of the .NET framework, and of ASP.NET MVC applications in particular, while baking in current best practices like dependency injection, strongly typed configuration, and logging. On top of that, you could build and deploy cross-platform. I was sold.
This book came about largely due to my approach to learning about ASP.NET Core. Rather than simply reading documentation and blog posts, I decided to try something new and start writing about what I learned. Each week I would dedicate some time to exploring a new aspect of ASP.NET Core, and Id write a blog post about it. When the possibility of writing a book came about, I jumped at the chanceanother excuse to dive further into the framework!
Since I started this book, a lot has changed, both with the book and ASP.NET Core. The first major release of the framework in June 2016 still had many rough edges, in particular around the tooling experience. With the release of .NET 5.0 in November 2020, ASP.NET Core has really come into its own, with the APIs and tooling reaching mature levels. This book targets the .NET 5.0 release of ASP.NET Core, but as long as youre using at least .NET Core 3.1, you will be able to follow along without any issues.
This book covers everything you need to get started with ASP.NET Core, whether youre completely new to web development or youre an existing ASP.NET developer. It focuses very much on the framework itself, so I dont go into details about client-side frameworks such as Angular and React or technologies like Docker. I also dont cover all the new features in .NET 5.0 such as Blazor and gRPC. Instead, I provide links where you can find more information.
We'll focus on building server-rendered applications using Razor Pages and Web APIs using MVC controllers. Youll learn the fundamentals of ASP.NET Core, such as middleware, dependency injection, and configuration, and how to customize each for your requirements. Youll learn how to add authentication and authorization to your apps, how to improve their security, and how to deploy and monitor them. Finally, youll learn how to test your applications using both unit tests and integration tests.
Personally, I find it a joy working with ASP.NET Core apps compared to apps using the previous version of ASP.NET, and I hope that passion comes through in this book!
acknowledgments
While there is only one name on the cover of this book, a plethora of people contributed to both its writing and production. In this section Id like to thank everyone who encouraged me, contributed, and put up with me for the past year.
Firstly, and most importantly, Id like to thank my girlfriend, Becky. Your continual support and encouragement mean the world to me and have kept me going through such a busy time. Youve taken the brunt of my stress and pressure, and Im eternally grateful. I love you always.
Id also like to thank my whole family for their support. In particular my parents, Jan and Bob, for putting up with my ranting, and my sister, Amanda, for all your upbeat chats.
On a professional level, Id like to thank Manning for giving me this opportunity. Brian Sawyer discovered me in the first version of this book and encouraged me to tackle the second version. Marina Michaels served as my development editor for the second time running, and again proved alternately meticulous, critical, encouraging, and enthusiastic. The book is undoubtedly better thanks to your involvement. Thanks also to Deirdre Hiam, my project editor; Andy Carroll, my copyeditor; Jason Everett, my proofreader; and Mihaela Batinic, my reviewing editor.