Modern Web Development with ASP.NET Core 3
eBook - ePub

Modern Web Development with ASP.NET Core 3

An end to end guide covering the latest features of Visual Studio 2019, Blazor and Entity Framework, 2nd Edition

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

Modern Web Development with ASP.NET Core 3

An end to end guide covering the latest features of Visual Studio 2019, Blazor and Entity Framework, 2nd Edition

About this book

Explore the tools and techniques to build scalable and secured RESTful web services and web applications using C# 8 and ASP. NET Core 3.1

Key Features

  • Delve into MVC patterns, configuration, routing, and deployment to build professional-grade applications
  • Learn how to integrate ASP applications with the JavaScript frameworks React, Vue, and Angular
  • Improve the performance of applications and the development team by implementing advanced ASP.NET Core concepts

Book Description

ASP.NET has been the preferred choice of web developers for a long time. With ASP.NET Core 3, Microsoft has made internal changes to the framework along with introducing new additions that will change the way you approach web development. This second edition has been thoroughly updated to help you make the most of the latest features in the framework, right from gRPC and conventions to Blazor, which has a new chapter dedicated to it.

You'll begin with an overview of the essential topics, exploring the Model-View-Controller (MVC) pattern, various platforms, dependencies, and frameworks. Next, you'll learn how to set up and configure the MVC environment, before delving into advanced routing options. As you advance, you'll get to grips with controllers and actions to process requests, and later understand how to create HTML inputs for models. Moving on, you'll discover the essential aspects of syntax and processes when working with Razor. You'll also get up to speed with client-side development and explore the testing, logging, scalability, and security aspects of ASP.NET Core. Finally, you'll learn how to deploy ASP.NET Core to several environments, such as Azure, Amazon Web Services (AWS), and Docker.

By the end of the book, you'll be well versed in development in ASP.NET Core and will have a deep understanding of how to interact with the framework and work cross-platform.

What you will learn

  • Understand the new capabilities of ASP.NET Core 3.1
  • Become well versed in how to configure ASP.NET Core to use it to its full potential
  • Create controllers and action methods, and understand how to maintain state
  • Implement and validate forms and retrieve information from them
  • Improve productivity by enforcing reuse, process forms, and effective security measures
  • Delve into the new Blazor development model
  • Deploy ASP.NET Core applications to new environments, such as Microsoft Azure, AWS, and Docker

Who this book is for

If you are a developer with basic knowledge of ASP.NET MVC and want to build powerful applications, then this book is for you. Developers who want to explore the latest changes in ASP.NET Core 3.1 to build professional-level applications will also find this book useful. Familiarity with C#, ASP.NET Core, HTML, and CSS is expected to get the most out of this book.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
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.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
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.
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.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Modern Web Development with ASP.NET Core 3 by Ricardo Peres 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

Section 1: The Fundamentals of ASP.NET Core 3
This first section will cover the fundamentals of ASP.NET Core and the Model-View-Controller (MVC) pattern and how the two meet, and .NET Core and its concepts will be explored.
This section has the following chapters:
  • Chapter 1, Getting Started with ASP.NET Core
  • Chapter 2, Configuration
  • Chapter 3, Routing
  • Chapter 4, Controllers and Actions
  • Chapter 5, Views
Getting Started with ASP.NET Core
Welcome to my new book on ASP.NET Core 3!
.NET and ASP.NET Core are relatively new in the technological landscape, as they were onlyofficially released in August 2017. Given that .NET is in the name, you would think that these would probably only be new versions of the highly popular .NET Framework, but that is not the case: we are talking about something that is truly new!
It's not just multiplatform support (howdy, Linux!), but it's so much more. It's the new modularity in everything: the transparent way by which we can now change things—the source code in front of our eyes teasing us to contribute to it, to make it better—is indeed a lot different from previous versions of .NET Core!
In this first chapter, we are going to talk a bit about what changed in ASP.NET and .NET in the core versions, and also about the new underlying concepts, such as OWIN, runtime environments, and dependency injection (DI).
In this chapter, we will cover the following topics:
  • History of ASP.NET Core
  • Introduction to .NET Core
  • Inversion of control and DI
  • OWIN
  • The MVC pattern
  • Hosting
  • Environments
  • How the bootstrap process works for ASP.NET Core apps
  • The generic host
  • What's new since ASP.NET Core 2
  • The NuGet and dotnet tools

Technical requirements

This chapter does not require any particular software component, as it deals more with concepts.
You can find the GitHub link at https://github.com/PacktPublishing/Modern-Web-Development-with-ASP.NET-Core-3-Second-Edition.

Getting started

Microsoft ASP.NET was released 15 years ago, in 2002, as part of the then shiny new .NET Framework. It inherited the name ASP (short for Active Server Pages) from its predecessor, with which it barely shared anything else, other than being a technology for developing dynamic server-side content for the internet, which ran on Windows platforms only.
ASP.NET gained tremendous popularity, it has to be said, and competed hand to hand with other popular web frameworks, such as Java Enterprise Edition (JEE) and PHP. In fact, it still does, with sites such as BuiltWith giving it a share of 21% (ASP.NET and ASP.NET MVC combined), way ahead of Java (https://trends.builtwith.com/framework). ASP.NET was not just for writing dynamic web pages. It could also be used for XML (SOAP) web services, which, in early 2000, were quite popular. It benefited from the .NET Framework and its big library of classes and reusable components, which made enterprise development almost seem easy!
Its first version, ASP.NET 1, introduced web forms, an attempt to bring to the web the event and component model of desktop-style applications, shielding users from some of the less friendly aspects of HTML, HTTP, and state maintenance. To a degree, it was highly successful; using Visual Studio,you could easily create a data-driven dynamic site in just a few minutes! A great deal of stuff could be accomplished merely through markup, with no code changes (read or compile) needed.
Version 2 came along a few years afterward, and among all the other goodies, it brought with it extensibility in the form of a provider model. A lot of its functionality could be adapted by the means of custom providers. Later on, it received the addition of the AJAX Extensions, which made AJAX-style effects astonishingly easy. It set the standard for years to come, leaving only room for more components.
To be honest, the following versions, 3.5, 4, and 4.5, only offered more of the same, with new specialized controls for displaying data and charts for retrieving and manipulating data and a few security improvements. A big change was that some of the framework libraries were released as open source.
Between versions 3.5 and 4, Microsoft released a totally new framework, based on the model-view-controller (MVC) pattern, and it was mostly open source. Although it sits on top of the infrastructure laid out by ASP.NET, it offered a whole new development paradigm, which this time fully embraced HTTP and HTML. It seemed to be the current trend for web development across technologies, and the likes of PHP, Ruby, and Java, and .NET developers were generally pleased with it. ASP.NET developers nowhad two choices—Web Forms and MVC, both sharing the ASP.NET pipeline and .NET libraries, but offering two radically different approaches to getting content to the browser.
In the meantime, the now venerable .NET Framework had grown up in an ever-changing world. In the modern enterprise, the needs have changed, and sentences such as runs on Windows only or we need to wait XX years for the next version became barely acceptable. Acknowledging this, Microsoft started working on something new, something different that would set the agenda for years to come. Enter .NET Core!
In late 2014, Microsoft announced .NET Core. It was meant to be a platform-independent, language-agnostic, free, and open source full rewrite of the .NET Framework. Its main characteristics were as follows:
  • The base class libraries of .NET were to be rewritten from scratch while keeping the same (simplified) public APIs, which meant that not all of them would be initially available.
  • It was also able to run on non-Windows operating systems, specifically several Linux and macOS flavors, and in mobile devices, so all Windows-specific code (and APIs) would be discarded.
  • All of its components were to be delivered as NuGet packages, meaning that only a small bootstrap binary would need to be installed in the host machine.
  • There was no longer a dependency (or, let's say, a very close relationship) with IIS, so it was able to be autohosted or run inside a hosting process, like, well, IIS.
  • It would be open source and developers would be able to influence it, either by creating issues or by submitting pull requests.
This eventually took place in July 2016, when version 1.0 of .NET Core was released. The .NET developers could now write once and deploy (almost) everywhere and they finally had a say on the direction the framework was taking!
Rewriting the whole .NET Framework from scratch is a task of epic proportions, so Microsoft had to make decisions and define priorities. One of them was to ditch ASP.NET Web Forms and to only include MVC. So gone were the days when ASP.NET and Web Forms were synonyms, and the same happened with ASP.NET Core and MVC: it's now just ASP.NET Core! And it's not just that the ASP.NET Web API, which used to be a different project type, was now merged with ASP.NET Core as well (a wise decision from Microsoft, as basically the two technologies, MVC and Web API, had a lot of overlap and even had classes with the same name for pretty much the same purpose).
So, what does this mean for developers? Here are my personal thoughts about how the tech has fared:
  • C#, Visual Basic, and F#; F# has gained a lot of momentum among the developer communities, and they have built templates for Visual Studio as...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Dedication
  4. About Packt
  5. Contributors
  6. Preface
  7. Section 1: The Fundamentals of ASP.NET Core 3
  8. Getting Started with ASP.NET Core
  9. Configuration
  10. Routing
  11. Controllers and Actions
  12. Views
  13. Section 2: Improving Productivity
  14. Using Forms and Models
  15. Implementing Razor Pages
  16. API Controllers
  17. Reusable Components
  18. Understanding Filters
  19. Security
  20. Section 3: Advanced Topics
  21. Logging, Tracing, and Diagnostics
  22. Understanding How Testing Works
  23. Client-Side Development
  24. Improving Performance and Scalability
  25. Real-Time Communication
  26. Introducing Blazor
  27. gRPC and Other Topics
  28. Application Deployment
  29. Appendix A: The dotnet Tool
  30. Assessments
  31. Other Books You May Enjoy