Book Image

ASP.NET Core 2 Fundamentals

By : Onur Gumus, Mugilan T. S. Ragupathi
Book Image

ASP.NET Core 2 Fundamentals

By: Onur Gumus, Mugilan T. S. Ragupathi

Overview of this book

The book sets the stage with an introduction to web applications and helps you build an understanding of the tried-and-true MVC architecture. You learn all about views, from what is the Razor view engine to tagging helpers. You gain insight into what models are, how to bind them, and how to migrate database using the correct model. As you get comfortable with the world of ASP.NET, you learn about validation and routing. You also learn the advanced concepts, such as designing Rest Buy (a RESTful shopping cart application), creating entities for it, and creating EF context and migrations. By the time you are done reading the book, you will be able to optimally use ASP.NET to develop, unit test, and deploy applications like a pro.
Table of Contents (14 chapters)

Preface

The book sets the stage with an introduction to web applications and helps you to build an understanding of the tried-and-true MVC architecture. You learn all about views, from what is the Razor view engine to tagging helpers. You gain insight into what models are, how to bind them, and how to migrate databases using the correct model. As you get comfortable in the world of ASP.NET, you learn about validation and routing. You also learn advanced concepts, such as designing a RESTful application, creating entities for it, and creating EF context and migrations. 

This book balances theory and exercises, and contains multiple open-ended activities that use real-life business scenarios for you to practice and apply your newly acquired skills in a highly relevant context. We have included over 60 practical activities and exercises across 38 topics to reinforce your learning. By the time you are done reading the book, you will be able to optimally use ASP.NET to develop, unit test, and deploy applications like a pro.

Who this book is for

If you are looking to build web applications using ASP.NET Core or you want to become a pro in building web applications using the Microsoft technology, this is the ideal book for you. Prior exposure and understanding of C#, JavaScript, HTML, and CSS syntax is assumed. This book is written at the time of .NET Core 2.0 preview.

What this book covers

Chapter 1, Setting the Stage, begins with explaining the fundamental concepts about web applications—HTTP, client side, and server side. It also discusses the three programming models of ASP.NET MVC. Finally, it provides simple and easy-to-follow step-by-step instructions to set up an ASP.NET Core Web Application project and project structure.

Chapter 2, Controllers, explains the role of the controller in ASP.NET MVC applications. It also details the procedure of creating a controller and action methods. It also describes how to make modifications to the controller, such that it uses the view. Finally, it describes how to add a model and pass that model data to your view.

Chapter 3, Views, is more hands-on in nature as it teaches how to program in the Razor view engine and use different programming constructs. It also explains in depth how to create and call partial views, create a view component, and create custom Tag Helpers.

Chapter 4, Models, explains how models in ASP.NET MVC are used to represent the business domain data. It begins by explaining how to create a simple model and a model specific to ViewModel. It then provides the step-by-step guidance on how to use Entity Framework in ASP.NET MVC applications. 

Chapter 5, Validation, describes the importance of validating the input data before storing the data for further processing. It begins with a brief explanation of the different types of validation. Moves on to explain how to perform both client-side and server-side validations by using an example. Finally, it covers how to use jQuery libraries to perform unobtrusive JavaScript validation.

Chapter 6, Routing, discusses routing along with several options available for customizing it in ASP.NET. Firstly, it teaches how to configure routing using MapRoute. It then, through examples, teaches how to work with different types of routing.

Chapter 7, Rest Buy, details the development of a simple shopping cart application called Rest Buy. As with how most projects begin, it discusses the design of Rest Buy. Then, it moves on to discuss the entities for the application. Finally, it deals with EF context and migrations.

Chapter 8, Adding Features, Testing, and Deployment, is built around adding the registration feature to our application and testing and deploying it to the cloud. It, therefore, deals with writing unit tests and upgrading it to Bootstrap 4. It also details how to deploy our application to Azure.

To get the most out of this book

You need to have a computer system equipped with the following hardware and software:

  • For an optimal experience, we recommend the following hardware configuration:
    • Processor: 3.2 GHz or faster processor (Dual core with multi-threading)
    • Memory: 4 GB of RAM (1.5 GB if running on a virtual machine)
    • Storage: Installations require 20-50 GB of free Hard disk space (depending on features installed the requirement can go up to 130 GB of available space)

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/TrainingByPackt/Beginning-ASP_DOT_NET. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

 

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

public class ValuesController : Controller
{
  // GET api/<controller>
  public IEnumerable<string> Get()
  {
    return new string[] { "value1", "value2" };
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Open up Visual Studio 2017. Navigate to File | New Project | Web."

Note

Warnings or important notes appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.