ASP.NET Core Razor Deep Dive

This course will explore, in depth, the new capabilities provided by Razor in .NET Core as well as the great features from past versions that are still part of this latest release.
Course info
Rating
(100)
Level
Intermediate
Updated
Dec 20, 2016
Duration
4h 14m
Table of contents
Course Overview
Putting Razor into Context
Getting Started with Razor Basics
Building Better Forms with Razor
Building for Reusability with View Components
Working with Dependency Injection in Razor
Writing Cleaner Markup with Tag Helpers
Extending and Configuring Razor
Creating Efficient Markup with Razor Templating
Description
Course info
Rating
(100)
Level
Intermediate
Updated
Dec 20, 2016
Duration
4h 14m
Description

A deep understanding of the Razor View Engine enables you to build better MVC Applications. Many developers become comfortable with the general syntax of Razor, but are unaware of the full depth of features it has to offer. This course, ASP.NET Core Razor Deep Dive, will help to fill those knowledge gaps with a rich understanding of Razor's full potential. You'll start by becoming comfortable with core concepts like Views, Layouts, and Helper Methods. You will also discover the new capabilities provided by Razor in .NET Core, such as View Components and Tag Helpers, as well as the great features from past versions that are still part of this latest release. Once you're comfortable working with Razor, you'll learn more advanced techniques like how to extend and customize Razor, how to implement Dependency Injection, and how to utilize templating. By the end this course, you'll understand the full set of features Razor offers to help build MVC applications, and feel comfortable applying them to your own future applications.

About the author
About the author

Alex Wolf is passionate about software development and mastering new technologies. He has several years of experience working almost exclusively with the .NET Framework and related platforms. Alex is also a Microsoft Certified Professional in both MVC Application development and HTML 5 technologies. He loves learning new things!

More from the author
Android: Image Processing with Picasso
Beginner
1h 57m
Mar 9, 2018
More courses by Alex Wolf
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone, my name is Alex Wolf and welcome to this course ASP. NET Core Razor Deep Dive. I've been working with. NET MVC and Razor since their inception, so I'm excited to present this course on some of the latest and greatest features it has to offer. Razor provides a powerful productivity tool set for working with MVC applications. Many developers become comfortable with the general syntax of this view engine, but are unaware of the full depth of features it has to offer. The goal of this course is to fill those gaps with a rich understanding of Razor's full potential. Now Razor has experienced some significant changes in. NET core. The best features from past versions are still around, but many powerful new capabilities have been added as well. We'll be sure to cover all of these tools by working with an approachable sample application. Whether you're just getting started with Razor or looking to deepen your knowledge, you're in the right place. Some of the major topics that we'll cover include core concepts, like views, layouts, and helper methods. We'll also explore the powerful new View Components feature, as well as how to get started with the new Tag Helper syntax. Together we'll see how to extend and customize Razor and work with more advanced topics like dependency injection. By the end of this course, you'll understand the full set of features Razor offers to help build. NET Core MVC applications. You'll gain a deeper understanding of existing Razor features and feel comfortable exploring the new tools it offers for your future applications. Now before starting the course, you should be familiar with basic web languages, like HTML and CSS, a basic working knowledge of the. NET framework is also very useful. Of course, any MVC specific knowledge will also help, but is not required. So I hope you'll join me on this journey to really mastering Razor with this course ASP. NET Core Razor Deep Dive, right here on Pluralsight.

Putting Razor into Context
Hi, I'm Alex Wolf and welcome to this deep dive into Razor in ASP. NET Core. There are many interesting changes in this latest version of MVC and Razor is no exception. In this first module, our primary goal is to establish context for the rest of the course. We want to understand Razor's place in the MVC framework and how it helps to fulfill the promise of MVC design patterns, specifically at the view layer. With all of the changes happening around ASP. NET in the latest version, we also want to discuss how Razor has evolved since previous versions. Which features have been migrated from MVC 5 and which have been left behind. What new features and improvements have been added in. NET Core to keep Razor compelling and relevant. Just as importantly, we also want to understand Razor's place in the larger development ecosystem. Is Razor still relevant in an industry flooded with front end JavaScript frameworks, like Angular and Polymer and Meteor? These technologies excel at advanced templating, model binding, markup generation, and much more. Do we still need a server side templating and markup generator? Finally I'll provide a tour of the sample project we'll be working with to demonstrate concepts in the modules ahead. The visual nature of Razor can really make it enjoyable to learn, so we'll have plenty of demos that provide quick results and feedback. Now I like to keep introductory content as brief and to the point as possible. So let's move right along to the next lesson where we'll determine whether this course is a good fit for where you are as a developer.

Getting Started with Razor Basics
Hi, I'm Alex Wolf and in this module let's begin to work directly with Razor. Let's start building some of the features of our application. Up until now our discussions have been primarily conceptual, but this module consists mostly of practical demos. We'll begin by getting comfortable with Razor syntax and how to make server side expressions with our standard HTML markup. Once we understand the look and feel of Razor, we'll begin to explore its most core features, views and layouts. This will allow us to build out the basic structure of our sample application. We'll also look at how to pull in the correct styling and JavaScript resources to make sure everything renders correctly. We can then start to use our first HTML helpers, starting with some basic utilities helpers that will help us build our navigation. To finish the basic layout of our app, we will implement Razor sections and see just how they can give us more control over our view content. Finally, we'll start to add logic and render lists of data and explore the relationship between action methods and views. We have plenty of work ahead of us in this module, so let's start working hands on with Razor in the next lesson.

Building Better Forms with Razor
In this module let's focus on creating forms with the Razor view engine. Razor offers an extensive set of features built around forms that are designed to really improve productivity. Building effective form workflows also requires some understanding of other MVC components, so we'll be sure to explore those topics as necessary. We'll start by discussing how forms integrate with models in MVC. This relationship is important for creating strongly typed views and setting up effective model binding for our form submissions. We'll then build our first form using these concepts. Model binding is one of the most powerful features of MVC, so we'll be sure to spend time thoroughly exploring how it works and walk through an example of that as well. In order to guarantee the integrity of our forms for both the user and the application itself, we'll also spend time in form validation. This will include how to check for and display errors on the client side, as well as how to secure our application on the server side. Finally, we'll also look at more advanced model binding scenarios with collections and see how MVC handles these types of data structures. This module we'll really start to go deeper into Razor, so let's get started in the next clip.

Building for Reusability with View Components
Hi there, I'm Alex Wolf, and in this module we want to discuss view components in MVC Core. View components are one of the most significant new features in the latest version of Razor. They can really impact the way you structure the views and logic of your application. We'll being this discuss by exploring partial views, which provide the basic building blocks for view components. We'll also see how this useful feature of Razor can improve the organization of our application. We'll then explore the evolution of partial views by delving into view components. What functionality can view components offer and how do they compare to legacy features of Razor, like child actions. Once we understand these essential concepts, we can build our first view component. There are many different implementations and use cases for these components, but we'll cover some of the most productive and common ways to utilize them. After we have a working view component, we want to explore the benefits this provides to our application. So we'll see an example of how our component provides reusability and how to add parameters to customize how it displays. We'll also step through a demo of how view components provide isolation to protect the other layers of our application. Finally, we'll work with a more advanced view component example. This component will demonstrate how to handle user interaction through Ajax and even integrate with a controller. The best way to learn how to build view components is by working hands on with different types of examples, so let's move ahead in this process in the next clip.

Working with Dependency Injection in Razor
Hi there, I'm Alex Wolf and in this module we want to explore how dependency injection integrates with Razor and MVC Core. The larger. NET Core platform features strong support for this design pattern and learning to work with it can improve the code quality of your applications. Now if you aren't familiar with dependency injection, there's no need to worry. This module will provide a high level introduction to the important concepts. As long as you understand the benefits of DI and how it integrates with Razor by the end of this module, you'll be just fine for the purposes of this course. So we'll begin this module with an overview of the core concepts of dependency injection. This will include understanding why we need dependency injection and the benefits it can provide to your application. Once we're on the same page conceptually, we'll see how to empower one of our view components with dependency injection. We'll also add DI to a second view component in order to illustrate some of the concepts around managing object lifetimes through containers. We will also discuss how to use dependency injection directly inside of views. Now adding business logic to your views is a concept that should be approached with caution, but we'll discuss when it might be appropriate and look at a possible use case for this. Finally, we'll step through a quick example of how to replace the built in. NET Core dependency injection features with third party options. We have our work cut out for us in this module, so let's get started with an overview of dependency injection in the next clip.

Writing Cleaner Markup with Tag Helpers
Hi, I'm Alex Wolf, and in this module let's begin to explore Tag Helpers, which are perhaps the most extensive new feature of Razor in MVC Core. Now this module will cover how to use the built in tag helpers provided by MVC. Later in the course I'll also touch on how to start building your own tag helpers, which is a fairly in depth subject. Tag helpers are rich enough that they could probably fill an entire course of their own, but we'll definitely cover enough to get you started in a meaningful way. We'll start by discussing just what tag helpers are and why they were introduced in. NET Core. We'll then look at an example of using tag helpers for simple tasks, like adding new navigation links. We'll also see how we can use these helpers to improve the way we manage our JavaScript and CSS resources. Once we're comfortable with the general workflow of tag helpers, we'll then prepare our project for another form and use tag helpers to build it. We will also see how we can apply validation to the form to improve our data quality and the user experience. Finally, we'll wrap things up with a closer comparison of tag helpers and the HTML helpers that we looked at earlier in the course. So let's get started in the next clip by discussing the role tag helpers play in MVC Core.

Extending and Configuring Razor
Hello again, I'm Alex Wolf, and in this module let's explore how we can extend and configure the Razor view engine. Razor is powerful and flexible, but there are many cases when the built in functionality doesn't provide exactly what you need. Fortunately Razor is designed with these situations in mind and offers several extension points that can help to fill these gaps. So we'll start by continuing our progress with tag helpers from the previous module by discussing the flexibility offered by custom tag helpers. Authoring tag helpers is a fairly expansive topic, but we'll get started with a simple example of a custom helper that can be applied as an attribute on existing HTML. We'll also explore a second custom tag helper that introduces a few other concepts, like creating entirely custom HTML elements. HTML helpers also offer this type of customization, so we'll see how we can customize them to improve the markup in our views or compensate for missing functionality. Once we understand how to extend HTML and tag helpers, we want to dive deeper into the internals of the view engine itself. We'll first explore in more depth just what a view engine is and then we'll see how we can customize the way it searches for views. We'll also spend a bit of time looking at Razor under the hood to better understand how it compiles and renders views. This module covers a variety of interesting topics that can take your Razor skills to the next level, so let's get started in the next clip.

Creating Efficient Markup with Razor Templating
Hi, I'm Alex Wolf and in this module we're going to learn about the templating features provided by Razor. Templates are another feature that can provide code reusability and help keep your Razor views clean. A major component of templating is metadata, so we'll also be revisiting the models of our application to see how we can optimize them for our Razor code. So first we'll begin with a discussion of the templating options offered by Razor and some of the high level concepts behind them. We'll then work on implementing our first templated HTML helpers and see what kind of impact this has on our views. We'll also see how we can override some of the built-in templates that Razor uses when rendering your model properties. You can also create templates for custom classes and data types in your application, so we'll explore a useful example of that as well. Additionally, Razor offers options for creating more miscellaneous templates that you could use for your own specific situations. We'll then see how we can use model level templates that provide advanced scaffolding options for our views, which can drastically reduce our markup. Finally, we'll also look at how to apply metadata on auto generated classes from technologies like Entity Framework, so you understand how to leverage templating in a variety of scenarios. Let's get started in the next clip with a high level discussion of essential templating concepts.