Items By Type: Tutorial

Using Unobtrusive Ajax In Razor Pages

17 September 2018 08:17

AJAX ASP.NET Core Razor Pages

There are a few demonstrations showing how to use the jQuery Unobtrusive AJAX library in ASP.NET Core, but existing examples tend to feature MVC applications. This article looks at how to use Unobtrusive AJAX in a Razor Pages setting, where it will help to remove a lot of the boilerplate associated with making AJAX requests.

Click to read more about Using Unobtrusive Ajax In Razor Pages ...

Partials and AJAX In Razor Pages

07 September 2018 15:57

AJAX ASP.NET Core Razor Pages

Updating portions of a page using AJAX and partial views is a routine task in ASP.NET MVC applications. The experience is little different in ASP.NET Core Razor Pages - not much, but enough to stump some people. Here is some advice on accomplishing this task, and a preview of some additional help coming in the near future.

Click to read more about Partials and AJAX In Razor Pages ...

Areas In Razor Pages

03 September 2018 08:01

ASP.NET Core Razor Pages

Support for Areas was added to Razor Pages with the release of ASP.NET Core 2.1. They have long been used in MVC applications as a way to separate logical chunks of large applications into semi-independent modules to facilitate team working etc. Here, I explore how to use areas in a Razor Pages application.

Click to read more about Areas In Razor Pages ...

Accessing The Model From Filters In Razor Pages

29 August 2018 08:23

ASP.NET Core Razor Pages

Support for filters was added to Razor Pages with the release of ASP.NET Core 2.1. Filters, for those unfamiliar with them, are components that enable the injection of processing at certain points within the Razor Page lifecycle. They differ from Middleware in that they provide access to the HttpContext. Razor Pages offers a number of different filter options. One of the things that you might want to do in a filter is to obtain data from an external resource (database, web service etc) and then use it in the PageModel or ViewData. Here, I take a look at how you can access the model or ViewData dictionary depending on the type of filter implementation that you choose.

Click to read more about Accessing The Model From Filters In Razor Pages ...

Query Types in Entity Framework Core

15 August 2018 13:46

Entity Framework ASP.NET Core

Query Types, introduced in Entity Framework Core 2.1 enable you to return non-entity types that map to tables or views and can serve as the return type from FromSql method calls.

Click to read more about Query Types in Entity Framework Core ...

Razor Pages, TypeScript and Knockout

16 July 2018 07:54

Javascript ASP.NET Core Razor Pages TypeScript

In this article, I look at the steps required to get TypeScript up and running in the context of a Razor Pages application. I discuss why you might want to do this, and I use Knockout for the purposes of demonstration. By the end of the article, I will have configured and used TypeScript to replicate part of the final code for the Single Page Application tutorial from learn.knockout.com.

Click to read more about Razor Pages, TypeScript and Knockout ...

Improved Cascading Dropdowns With Blazor

05 July 2018 13:27

C# Blazor

In my last article, I looked at the experimental Blazor framework, using Cascading Dropdown Lists as an entry point. Since then, some feedback from Steve Sanderson to a question I asked has shown me a better way to implement this pattern.

Click to read more about Improved Cascading Dropdowns With Blazor ...

Cascading Dropdowns With Blazor

24 May 2018 20:51

ASP.NET Core Blazor

Blazor is an experimental framework introduced by Steve Sanderson of Knockout.js fame (among other things) on the ASP.NET team. The premise of the framework is simple, but potentially game-changing for ASP.NET developers: it enables you to write your client side code in C#. What this means is that rather than having to chase after the latest Javascript-based hotness - Aurelia, React, Angular etc, only to find that they are dependent on learning a whole new load of frameworks, or that they are no longer flavour of the week, you just use the .NET skills that you already have to move your processing to the browser.

Click to read more about Cascading Dropdowns With Blazor ...

Working With JSON in Razor Pages

21 May 2018 13:49

ASP.NET Core Razor Pages

UI generation and processing within web applications is moving increasingly to the client. Data processing and storage is still undertaken on the server, with JSON being the preferred format for exchanging data between the server and the client. There are a number of ways in which you can generate JSON when working with Razor Pages. This article explores some of them.

Click to read more about Working With JSON in Razor Pages ...

Extending the Command Timeout in Entity Framework Core Migrations

26 March 2018 08:50

Entity Framework ASP.NET Core

Most migrations that you execute when working with Entity Framework Core are likely to be straightforward - resulting in nothing more than an adjustment to the database schema. Sometimes, however, you might also want to include a task that requires longer than the default command timeout value (30 seconds in SQL Server) such as importing a lot of data.

Click to read more about Extending the Command Timeout in Entity Framework Core Migrations ...

Publishing Razor Pages Applications - Gotchas

22 March 2018 08:15

ASP.NET Core Razor Pages

I have just completed an article covering publishing a Razor Pages application to IIS on my Razor Pages dedicated site: learnrazorpages.com. While writing it (and publishing revised versions of the site) I uncovered a few stumbling blocks that might catch others out. So I thought they were worth highlighting here in their own post.

Click to read more about Publishing Razor Pages Applications - Gotchas ...

ViewModels and AutoMapper in Razor Pages

14 February 2018 08:13

ASP.NET Core Razor Pages

The Razor Pages PageModel class is part controller, part ViewModel. In this article, I take a look at the ViewModel part of the role that the PageModel plays, and how tools like AutoMapper can be used to reduce the amount of code you need to write when assigning values between your entity model and your ViewModel.

Click to read more about ViewModels and AutoMapper in Razor Pages ...

Customising Identity in Razor Pages

22 September 2017 14:16

ASP.NET Core Razor Pages ASP.NET Identity

The code for managing authentication in a Razor Pages application that is provided by the standard project template is a good starting point. However, chances are that you want to customise it to fit your own application needs. This article looks at the most common customisation requirements.

Click to read more about Customising Identity in Razor Pages ...

Introduction to Identity in Razor Pages

08 September 2017 08:09

ASP.NET Core Razor Pages ASP.NET Identity

Razor Pages uses ASP.NET Identity as its default membership and authentication system. This article is the first in a series that explores the various parts of ASP.NET Identity as it relates to Razor Pages, and starts with an overview of the files generated as part of the project templates.

Click to read more about Introduction to Identity in Razor Pages ...

Sending Email in Razor Pages

20 July 2017 07:24

ASP.NET Core Razor Pages

The Razor Pages framework is not the only thing to be introduced as part of .NET Core 2.0. A lot more of the existing full framework class libraries are also being ported across to .NET Core including System.Net.Mail. That means there is no longer any need to rely on third party libraries or services for email functionality in your .NET Core applications. So I thought I'd take the opportunity to illustrate sending email in a Razor Pages application.

Click to read more about Sending Email in Razor Pages ...