calendar_today 24 July 2019 19:44
Later this year, .NET Core 3.0 will be released. The main features include WPF and Windows Forms support (albeit only on the Windows operating system) and server-side Blazor. Razor Pages applications will also see some changes. I cover some of these as part of a guide to upgrading an application from 2.2 to 3.0. Then I have a quick look at some of the other new features. Note that the information in this article is based on Preview 6, and is subject to change.
calendar_today 15 July 2019 12:41
Every other day or so it seems, a new question is posted to one of the community forums that cover ASP.NET Core Razor Pages asking why an AJAX post doesn't appear to work, or results in an HTTP 400 error. This article explains the most common cause, and offers guidance on how to solve it.
calendar_today 08 May 2019 07:26
Sometimes, using the full ASP.NET Core Identity framework is overkill for small, one-user applications that require some form of authentication. I'm thinking about blog applications, or web-based utilities that have admin areas that only you should be allowed to reach. All you really want to do is authenticate against a user name and password stored in a config file or similar. You really don't need the ceremony of a database, EF Core, ApplicationDbContexts, SignInManagers, UserManagers etc. This article provides a step-by-step guide to implementing simple authentication using just cookies, while storing credentials securely without a database.
calendar_today 29 April 2019 08:45
Available from ASP.NET Core 2.2, parameter transformers enable the centralisation of logic for modifying the value of routes and route parameters in URLs generated by the anchor tag helper or the Url helper.
calendar_today 01 April 2019 09:16
Razor Page already includes a wide range of constraints that can be used to help disambiguate routes. It is also possible for you to create your own custom constraint and then register that with the routing system.
calendar_today 19 March 2019 08:22
Partial Views or Pages are primarily used as a means of including reusable snippets of HTML within one or more Razor Pages. This walkthrough illustrates how to take advantage of the power of the Razor templating system used by partial pages to generate HTML for other purposes, such as the body of a mail message.
calendar_today 12 February 2019 08:26
Exceptions in .NET represent an error condition in an executing program. Error conditions can come about as a result of a large number of causes, each represented by its own exception type. Most exceptions arise from logical errors in code, such as an attempt to work with an object that has not been instantiated (
NullRefrenceException), or to divide by zero (
DivideByZeroException). Other types of exceptions result from technical issues, which may or may not be temporary. Examples of such issues might include a database or mail server being unavailable, or insufficient file system permissions.
calendar_today 17 October 2018 13:32
Razor Class libraries (RCLs) were introduced in ASP.NET Core 2.1 as a way to package and distribute UI components to be referenced and consumed within a host application. You can see them as a fully functioning part of a web application packaged as a class libray. The templated management pages for ASP.NET Identity were included as a Razor Class Library in the project template in 2.1. The Identity UI RCL includes the Razor pages, Filters, a stub EmailService class that Identity uses, and local versions of both Bootstrap 3 and 4.
calendar_today 10 October 2018 08:35
This article builds on the simple paging functionality that was added to a Razor Pages application in my last article by showing how to add sorting functionality so that the user can determine the order in which results are displayed.
calendar_today 03 October 2018 07:49
This article attempts to demonstrate how to implement simple paging functionality in a Razor Pages application. I will explain the basics behind paging, and then use BootStrap 4 to render a variety of paging links, without resorting to Nuget packages for link generation.
calendar_today 26 September 2018 07:39
At its heart, the Razor Pages routing story is a simple one. It uses a convention of mapping URLs to files on disk. There are ways to customise how pages are found on an individual basis, but what if you want to change the default convention in its entirety? There is also a way to do that. And it's quite simple, as this article will demonstrate, using two real-world examples.
calendar_today 17 September 2018 08:17
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.
calendar_today 07 September 2018 15:57
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.
calendar_today 03 September 2018 08:01
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.
calendar_today 29 August 2018 08:23
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
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.
calendar_today 15 August 2018 13:46
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.
calendar_today 16 July 2018 07:54
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.
calendar_today 05 July 2018 13:27
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.
calendar_today 24 May 2018 20:51
calendar_today 21 May 2018 13:49
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.