ASP.NET Core 5 for Beginners
eBook - ePub

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

Share book
  1. 598 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

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

Book details
Book preview
Table of contents
Citations

About This Book

Learn how to build web applications efficiently using ASP.NET Core 5 with the C# programming language and related frameworks

Key Features

  • Build web apps and services and cross-platform applications using.NET and C#
  • Understand different web programming concepts with the help of real-world examples
  • Explore the new features and APIs in ASP.NET Core 5, EF Core, Visual Studio, and Blazor

Book Description

ASP.NET Core 5 for Beginners is a comprehensive introduction for those who are new to the framework. This condensed guide takes a practical and engaging approach to cover everything that you need to know to start using ASP.NET Core for building cloud-ready, modern web applications.

The book starts with a brief introduction to the ASP.NET Core framework and highlights the new features in its latest release, ASP.NET Core 5. It then covers the improvements in cross-platform support, the view engines that will help you to understand web development, and the new frontend technologies available with Blazor for building interactive web UIs. As you advance, you'll learn the fundamentals of the different frameworks and capabilities that ship with ASP.NET Core. You'll also get to grips with securing web apps with identity implementation, unit testing, and the latest in containers and cloud-native to deploy them to AWS and Microsoft Azure. Throughout the book, you'll find clear and concise code samples that illustrate each concept along with the strategies and techniques that will help to develop scalable and robust web apps.

By the end of this book, you'll have learned how to leverage ASP.NET Core 5 to build and deploy dynamic websites and services in a variety of real-world scenarios.

What you will learn

  • Explore the new features and APIs introduced in ASP.NET Core 5 and Blazor
  • Put basic ASP.NET Core 5 concepts into practice with the help of clear and simple samples
  • Work with Entity Framework Core and its different workflows to implement your application's data access
  • Discover the different web frameworks that ASP.NET Core 5 offers for building web apps
  • Get to grips with the basics of building RESTful web APIs to work with real data
  • Deploy your web apps in AWS, Azure, and Docker containers
  • Work with SignalR to add real-time notifications to your app

Who this book is for

This book is for developers who want to learn how to develop web-based applications using the ASP.NET Core framework. Familiarity with the C# language and a basic understanding of HTML and CSS is required to get the most out of this book.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is ASP.NET Core 5 for Beginners an online PDF/ePUB?
Yes, you can access ASP.NET Core 5 for Beginners by Andreas Helland, Vincent Maverick Durano, Jeffrey Chilberto, Ed Price in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in C#. We have over one million books available in our catalogue for you to explore.

Information

Year
2020
ISBN
9781800566316
Edition
1

Section 1 – Crawling

In this section, you will learn the basics of .NET Core 5, including an overview, goals/values, new features, and its history. We’ll also help you refresh your C# skills, and we’ll cover setting up your cross-platform environment, as well as building apps and pages with CSHTML, MVC, Razor Pages, and Blazor (by using a unified markup engine—Razor). Finally, we’ll explain the dependency injection software design pattern.
This section includes the following chapters:
  • Chapter 1, Introduction to ASP.NET Core 5
  • Chapter 2, Cross-Platform Setup
  • Chapter 3, Dependency Injection
  • Chapter 4, Razor View Engine
  • Chapter 5, Getting Started with Blazor

Chapter 1: Introduction to ASP.NET Core 5

.NET 5 is the latest and greatest in the .NET platform. .NET 5 is the successor of .NET Core 3.1 This chapter takes a short tour through the history of the .NET Framework before diving into what this version brings to the table. The chapter wraps up with a look at utilities and tools you will want to have before proceeding with exploring the details in the chapters that follow. We will cover a broad range of topics, including cross-platform usage of .NET, different methods for creating the visual layer, backend components such as identity and data access, as well as cloud technologies.
We will cover the following topics in this chapter:
  • Explaining ASP.NET Core
  • Refreshing your C# knowledge
  • Learning what's new with .NET 5 and C# 9
  • Understanding websites and web servers
  • Exploring Visual Studio Code
  • Leveraging Windows Terminal

Technical requirements

This chapter includes short code snippets to demonstrate the concepts that are explained. The following software is required:
  • Visual Studio 2019: Visual Studio can be downloaded from https://visualstudio.microsoft.com/vs/community/. The Community edition is free and will work for the purposes of this book.
  • Visual Studio Code: Visual Studio Code can be downloaded from https://code.visualstudio.com/Download.
  • .NET Core 5: The .NET Core framework can be downloaded from https://dotnet.microsoft.com/download/dotnet/5.0.
Make sure you download the SDK, and not just the runtime. You can verify the installation by opening Command Prompt and running the dotnet --info cmd as shown:
Figure 1.1 – Verifying the installation of .NET
Figure 1.1 – Verifying the installation of .NET
Please visit the following link to check the CiA videos: https://bit.ly/3qDiqYY
Check out the source code for this chapter at https://github.com/PacktPublishing/ASP.NET-Core-5-for-Beginners/tree/master/Chapter%2001/Chapter_01_HelloWeb.

Explaining ASP.NET Core

The first version of .NET was released in 2002, so it doesn't sound impressive that we're getting at version 5 since it's been 18 years. However, it is slightly more complicated than that, both with the numbering system and due to various sidetracks. A complete history could possibly be a book on its own, but to understand where we are now, we will take you on a short walk down memory lane.
When .NET came on the scene, there were a couple of options available to you for choosing a programming language depending on your scenario. Visual Basic was popular for introductory type programming since it was, as the name implies, visually oriented and easy to get started with. However, VB wasn't great for writing complex applications at scale with high performance. Windows itself was mostly written in C and C++ and was the preferred route for professional-grade software. While these languages were (and still are) highly capable, they were notorious for allowing the programmer to shoot themselves in the foot due to things such as making the coder responsible for memory management and other low-level operations that were hard to debug and troubleshoot.
In parallel with the language implementations offered directly from Microsoft, Sun Microsystems released Java as a solution to these challenges. Instead of producing native code, the tooling produced managed code that abstracted memory management and made things easier. The syntax of the language was in the C++ style, so transitioning from C++ was easy for developers looking to make the switch to Java. It was also a stated goal that the code written should be portable to multiple platforms. This was enabled by a Java Virtual Machine (JVM), which was installed to execute on a given system.

Managed versus unmanaged code

Programming languages have evolved over the years. Where the first computers were programmed by physically turning switches and levers, you can now write instructions where even non-programmers are able to figure out what some of the commands mean.
One often refers to the relative closeness to the computer's native language (zeros and ones) by referring a language as low-level (close) or high-level (abstract). At the lowest level, you have languages like assembler language, which theoretically have the least overhead (provided you can find highly talented programmers), but in addition to being complex, an assembler language is not portable across different CPU architectures. C# leans more towards the other end of the spectrum, with more natural language and many of the "hard things" are hidden from the programmer. And there are also languages that are even more high-level, such as Scratch (a block-based language), targeted at kids wanting to get into programming. (There is no formal definition of low versus high.)
One of the mechanisms C# uses to achieve this is by having an intermediate layer (for .NET this is the Common Language Runtime) that translates your code in real time to the underlying machine code understood by your computer. This means that the programmer does not need to handle allocating and releasing memory, does not interfere with other program's processes, and so on, and generally does a lot of the grunt work. To cater to the developers and enable them to create applications with a minimal re-learning experience, .NET was in demand for these platforms, but .NET was not built to run without the desktop components available.
The concept is not new to or unique for C#, and it is also the concept used in Java. Originally, it was conceived back in the IBM mainframe era. On personal computers, it was initially challenging since managed code will always have an overhead due to the translation that occurs, and on resource-constrained computers (when .NET 1.0 was released), it can run slow. Newer computers handle this much more efficiently, and .NET has been optimized over the years, so for most applications, it is not much of an issue any longer if the code is managed or not.

Introducing the .NET platform

Microsoft took inspiration from Java, as well as their learnings from the ecosystem they provided, and came up with .NET. The structure of the platform is displayed in Figure 1.2.
.NET was also based on managed code and required a Common Language Runtime (CLR) to be installed to execute. The C# language was released in the same time frame, but .NET also supported Visual Basic and J#, highlighting that it was a more generic framework. Other programming languages that required extra software to be installed for running applications h...

Table of contents