ASP.NET Core 5 for Beginners
Total Page:16
File Type:pdf, Size:1020Kb
ASP.NET Core 5 for Beginners Kick-start your ASP.NET web development journey with the help of step-by-step tutorials and examples Andreas Helland Vincent Maverick Durano Jeffrey Chilberto Ed Price BIRMINGHAM—MUMBAI ASP.NET Core 5 for Beginners Copyright © 2020 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Richa Tripathi Acquisition Editor: Denim Pinto Senior Editor: Rohit Singh Content Development Editor: Kinnari Chohan Technical Editor: Gaurav Gala Copy Editor: Safis Editing Project Coordinator: Francy Puthiry Proofreader: Safis Editing Indexer: Pratik Shirodkar Production Designer: Alishon Mendonsa First published: December 2020 Production reference: 1171220 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-80056-718-4 www.packt.com This book is dedicated to my family, for allowing me to spend countless hours in front of my computers both growing up and to this day, not to mention accepting the joys of me having a home lab – couldn’t have done it without you! Andreas Helland I dedicate this book to my kids: Vianne Maverich, Vynn Markus, and Vjor Morrison. To my wife, Michelle Anne, who’s always supported my hustle, drive, and ambition. I love you! Vincent Maverick Durano This book is dedicated to all the individuals that have influenced me in my career. From California to Vienna to Auckland, they have supported me, challenged me, and helped shape me. Jeffrey Allan Chilberto Packt.com Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? • Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals • Improve your learning with Skill Plans built especially for you • Get a free eBook or video every month • Fully searchable for easy access to vital information • Copy and paste, print, and bookmark content Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. Contributors About the authors Andreas Helland has a degree in software engineering and 20 years of experience in building products and services. He has worked both with the development side and the infrastructure side and holds a number of Microsoft certifications across both skill sets. This background led him to become an early adopter of Azure and the cloud. After building up his knowledge working in the telecommunications industry, he switched to consulting, and he currently works as an architect for Capgemini, where he assists customers with utilizing the cloud in the best ways possible. He specializes in Azure Active Directory and works closely with the Identity teams at Microsoft, both in testing new services and providing feedback based on learnings from the field. I want to thank Ed for roping me in on this project – of course there’s time available to write a book! Thanks to Vince and Jeffrey for bringing in their content and perspectives – it would have been a thin (and less exciting) book if it was only me doing the writing. I enjoyed working with you! Thanks to Packt for making sure there’s been plenty to do when we have to spend most of our time at home – books are the perfect companion activity for that. Vincent Maverick Durano works as a software engineer/architect at an R&D company based in Minnesota. His jobs include designing software, building products and services that impact the lives of people. He’s passionate about learning new technologies, tackling challenges, and sharing his expertise through writing articles and answering forums. He has authored several books and has over 15 years of software engineering experience. He has contributed to OSS projects and founded AutoWrapper and ApiBoilerPlate. He is a 10-time Microsoft MVP, 5-time C# Corner MVP, 3-time CodeProject MVP, and a contributor to various online technical communities. He’s from the Philippines and married to Michelle and has three wonderful children – Vianne, Vynn, and Vjor. I want to thank Ed for bringing me on board to be part of this book and to my other co-authors: Andreas and Jeff – you guys are awesome! It was fun and a great experience working with you. To Kinnari, Francy, and the Packt team – thank you! Jeffrey Chilberto is a software consultant specializing in the Microsoft technical stack, including Azure, BizTalk, ASP.NET, MVC, WCF, and SQL Server, with experience in a wide range of industries, including banking, telecommunications, and healthcare in the United States, Europe, Australia, and New Zealand. Special thanks to Kinnari, Francy, and the Packt Team for the drive and support; Andreas for his leadership and vision; Vince for his dedication and measured advice; and Ed for bringing the authors together, his wit, and his contributions to the ASP.NET community. Ed Price is a senior program manager in engineering at Microsoft, with an MBA in technology management. He has run Microsoft customer feedback programs for Azure development, Service Fabric, IoT, and Visual Studio. He was also a technical writer at Microsoft for 6 years, helped lead TechNet Wiki, and now leads efforts to publish Microsoft’s Reference Architectures on the Azure Architecture Center (focusing on web development scenarios). He is the co-author of four books, including Learn to Program with Small Basic and Hands-On Microservices with C# and .NET Core 3, Third Edition (from Packt). What do you do when the world is quarantined in 2020 from COVID- 19? You write a book! I want to thank the ASP.NET community and my amazing partners on this book: Andreas for being our technical leader, Vince for joining us last (only to show us up by providing the most content), and Jeffrey for being our rock and anchor (and for writing amazing run-on sentences in his biography). About the reviewers Adwait Ullal is a technology consultant based in Silicon Valley. He works with Fortune 500 companies to provide cloud and enterprise architecture guidance. Adwait’s prior experience includes application and solutions architecture, specializing in Microsoft technologies. Adwait has presented on cloud and enterprise architecture topics at local code camps and meetups. Francis Emefile is a software developer from Nigeria. It has always fascinated him how collaboration coupled with technology is capable of achieving great results. While at university studying electrical/electronic engineering, he gravitated towards computer programming out of curiosity and necessity. With the idea of building a hub where students could get information around campus, he soon discovered that his technical skill was not enough to bring his idea to life, so he taught himself programming. After graduation, he got a job as a software developer and has been building impactful and exciting products ever since. He is presently working with a bank, where he crafts code with an amazing team to build solutions for the bank’s huge customer base. Packt is searching for authors like you If you’re interested in becoming an author for Packt, please visit authors. packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Table of Contents Preface Section 1 – Crawling 1 Introduction to ASP.NET Core 5 Technical requirements 18 Web server configuration 46 Explaining ASP.NET Core 18 Certificate trust 46 Session stickiness 47 Managed versus unmanaged code 19 Troubleshooting communication with Introducing the .NET platform 20 web servers 48 Supportability strategy 25 Choosing a web server option 50 Refreshing your C# knowledge 26 Exploring Visual Studio Code 52 What's new in .NET 5? 36 Leveraging Windows Terminal 54 What's new in C# 9? 37 Summary 56 Understanding websites and Questions 56 web servers 45 Further reading 57 2 Cross-Platform Setup Technical requirements 60 What cross-platform does not do for you 63 Leveraging the .NET framework 60 Getting started on Windows, Why cross-platform? 61 Linux, and macOS