Book Image

ASP.NET Core Essentials

By : Shahed Chowdhuri
Book Image

ASP.NET Core Essentials

By: Shahed Chowdhuri

Overview of this book

<p>ASP.NET Core is the latest collection of Microsoft’s web application development technologies. When you’re trying to reach a broad spectrum of users with a robust web application, ASP.NET Core is there to help you build that application. With the ability to cater to users on desktop, tablet, or smartphone platforms, you can put together a solution that works well anywhere.</p> <p>This book is what you need to get started developing ASP.NET Core applications was quickly as possible; starting by introducing the software and how it can be used in today’s modern world of web applications and smartphone apps. Walking you through the benefits of a Web API to support both applications and mobile apps to give you a solid understanding of the tech to build upon as you see what ASP.NET Core can do for you.</p> <p>The book wraps up with practical guidelines for the use of database technologies, unit tests, security best practices, and cloud deployments for the real world.</p>
Table of Contents (15 chapters)
ASP.NET Core Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Bringing it all together


To bring it all together, let's make use of Visual Studio's built-in code generation features to take advantage of scaffolding and binding. In this section, we will cover field attributes that assist in model validation.

Before we wrap up this chapter, we will also learn about the use exception handling to catch errors in your code.

Scaffolding, validation, and model binding

Using the PatientRecords project we've built so far, let's add a new controller to it following the following steps, to make use of scaffolding. Instead of clicking on Add Item, we will choose the Controller option:

  1. In Solution Explorer, right-click the Controllers folder.

  2. In the context menu, click Add | Controller.

  3. Select the option to add a new MVC controller with views, using EF.

You will be prompted for additional information while adding your controller. Select/enter the following information:

  • Model class: Human, from your models namespace

  • Data context class: ApplicationDbContext

  • Controller name...