calendar_today 19 July 2021 10:54
CSS isolation was introduced in .NET 5 for Blazor components. Now it's coming to Razor Pages (and MVC views) in .NET 6, due to be released in November this year. Here's a quick look at how CSS isolation works in Razor Pages and the kind of problem that it's designed to solve.
calendar_today 24 November 2020 18:34
In my most recent article, I showed
how to create a custom model
binder to bind an ISO 8601 string representation of a week of the year
DateTime type in a Razor Pages application. The custom
model binder leant heavily on the existing infrastructure that binds
strings to simple types. Custom model binders are the correct solution
if you want to bind to simple types, but if you want to bind to a
complex type, the recommendation is to implement a
according to the offical docs. But the docs don't provide an example
that shows how to do that in the context of model binding. So here's
calendar_today 10 November 2020 15:28
In Razor Pages, model binding is the process that maps data from an HTTP request to simple PageModel properties or handler parameters. Incoming data can be included in a request as posted form values, query string values or route data. The default collection of model binders cover every simple .NET data type.. But sometimes they are not enough, and you need to add your own implementation.
calendar_today 02 November 2020 17:17
When working with dates and times in a Razor Pages form, you need to render a suitable control based in the task requirement. Prior to HTML5, developers largely depended on third party date picker libraries. Now, a variety of native browser options exist, although they enjoy varied support across modern browsers. These include options for managing the date and time, just the date or time, and for working with the month or week of the year.
calendar_today 19 June 2020 15:37
This short article shows how to display images stored in a database in a Razor Pages application using the Bootstrap Carousel and Entity Framework Core.
calendar_today 10 June 2020 12:34
Tabbed interfaces are a great way for managing the presentation of large amounts of information into separate panels, where each panel's data makes sense on its own, and only one panel is viewable at a time. The tabs in a browser are a great example of this. From a Razor Pages developer's point of view, tabs are particularly useful for controlling the display of complex data in Line Of Business applications.
calendar_today 28 May 2020 16:09
This is the first in a series of posts exploring how to use some of the components provided by Bootstrap within a database-driven Razor Pages web application. In this article, I look at using the Bootstrap Modal in a Master/Details scenario, to display the details of the selected record in a master list.
calendar_today 07 January 2020 07:37
This is the fourth article in a series that explores various aspects of localisation in ASP.NET Core Razor Pages applications. This article concentrates on the SEO aspects of localisation as they pertain to URL management, and how to utilise the RouteDataRequestCultureProvider to help you manage that.
calendar_today 17 December 2019 07:33
This is the third article in a series that explores various aspects of localisation in ASP.NET Core Razor Pages applications. The first article looked at how to work with cultures, and the second covered the basics of using resource files for static content translations. In this article, I explain how to provide localised resources for form labels and validation error messages for PageModel properties that have Data Annotation attributes applied to them.
calendar_today 10 December 2019 07:50
This is the second in a series of articles that cover localisation in ASP.NET Core Razor Pages applications. In the previous article, I looked at the basic configuration required to work with cultures which are the basic building block of localisation. I showed how to specify the cultures that the application supports, how to set the culture for the current request, and how some items, such as calendars are translated depending on the current culture. This article builds on the application which was introduced in the the last article and explores how to configure and use resources to store translated versions of static content.
calendar_today 03 December 2019 07:50
This is the first in a series of articles that explores localisation in ASP.NET Core Razor Pages applications. This article will look at the configuration required to prepare a site for content localisation, in other words, to globalise the site. Future articles will cover the creation of localised content and how to present it.
calendar_today 21 November 2019 13:11
When you port your Razor-based application to ASP.NET Core, whether its an
MVC application or a Web Pages application, you might notice that adding a
@functions block to your .cshtml file works as expected,
but any attempt to add a
@helpers block doesn't work at all.
calendar_today 13 November 2019 07:51
Remote Validation is a technique that uses client side script
to validate user input on the server without posting the entire form.
Remote validation has always been possible in Razor Pages using either the
RemoteAttribute, which requires an
MVC controller to work, or by writing custom client-side script. One almost completely overlooked feature that was
included in ASP.NET Core 3.0 was the introduction of a Razor Pages-specific
validation attribute that removes this reliance on MVC controllers or custom code for remote validation.
calendar_today 05 November 2019 13:50
The Blazor WebAssembly project template doesn't feature an option to include authentication. If you want to add authentication to a WebAssembly-based Blazor application, you need to do it yourself. This article shows how to add application-wide authentication management and then to use built-in Razor components to protect the FetchData page in the standard template from unauthorised users.
calendar_today 17 October 2019 07:47
A few weeks ago, Steve Sanderson blogged about publishing a package for a prototype Blazor file input component, designed to make working with user-supplied files in Blazor applications a lot easier. Steve has provided some very clear examples demonstrating how to use the component in a number of scenarios. Missing, though, is an example showing how to make an HTTP request to upload a file to some back-end server from a Blazor WebAssembly application.
calendar_today 11 October 2019 12:44
When passing data in a URL within a Blazor application, most of the time you will define route templates that incorporate parameter placeholders, passing values as URL segments. You might also find that you need to be able to work with query string values, so how do you do that in a Blazor application?
calendar_today 21 August 2019 20:11
Razor Pages routing is based on attribute routing and is very powerful. Parameters provide a way of passing arbitrary data to a page via the URL. Optional parameters allow URLs to matched to routes even if no parameter value is passed. Things can get a bit complicated if you want to permit multiple optional parameters.
calendar_today 05 August 2019 12:40
In my last article, I looked at some of the new things that ASP.NET Core 3.0 will introduce to Razor Pages developers. One of the features that I touched on was Razor Components. In this article, I take a more detailed look at what they are and how they can be used.
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.