Blazor: Cascading Values

Cascading values make it possible to make values and objects available to all components without the need to pass them along explicitly. The first rectangle on the top of this pic represents the root component. The row below it's children and the row below it their children and you could imagine this can go on for a while in a complex application. What if we have data that all or most of all these components need. For example something that defines a visual theme for all the components in an a...

Blazor: Chained Binds

A chained bind is binding a custom child component's property to a property of the parent component. Maybe you've already discovered how to two-way data bind an input element. That works with the @bind syntax to do a two-way databinding between the value of the input and a property of the parent component. An example: <input type="date" @bind="[PropertyName]" /> [PropertyName] here is the name of a property present in the parent, the component that renders the input. It can also be a proper...

I'm an ASP.NET Insider!

Happy to report that I'm now a member of the ASP.NET Insiders group. Here's the elevator pitch of the ASP.NET Insiders: > “The ASPInsiders is a select group of international professionals who  have demonstrated expertise in ASP.NET technologies and who provide  valuable, early feedback on related developing technologies and  publications to their peers, the Microsoft ASP.NET team and others.” To become an ASP.NET Insider one has to be voted in by other members. If you take a look at the names o...

Adding a GraphQL Endpoint to Your ASP.NET Core API

What is GraphQL? GraphQL is an open source specification created by Facebook that can be used to access data in APIs. GraphQL consist of two parts. In this pic there is a consumer of the API that can be any kind of application. The consumer sends a query to the API. Part one what GraphQL specifies is the format and syntax of the query. Part two is a runtime on the API that is able to process the query. When the runtime has processed the query it typically returns JSON, but that is not set in s...

Endpoint Routing in ASP.NET Core 2.2 Explained

The ASP.NET Core team is hard at work making ASP.NET Core better and more performant with each release. An enhancement in 2.2 is endpoint routing. Here's how it works. In pre-2.2 versions routing is done at the MVC level. A URL that hits the app is interpreted and mapped to the right controller and action according to the configuration you do in the routing table or with routing attributes. All the work is done in the MVC middleware. This has a drawback. Because this is at the MVC level oth...

Pluralsight Course "Understanding ASP.NET Core 2.x" Updated

My Pluralsight course about ASP.NET Core 2 is one of the most popular courses I have. Many people have already watched it and I'm thrilled about the very positive feedback I'm getting about it. There is 2.x in the title so the intention of the course is that I'm updating it as ASP.NET Core minor versions come out. Since the course was created when 2.0 was released I have now updated it to reflect version 2.1. Maybe you're thinking: that's a bit late. Well I finished the updates about 4 weeks a...

Writing APIs in ASP.NET Core 2.1 with the ApiController Attribute

APIs Writing Apis in ASP.NET Core until version 2.0 for me has been a great experience. I love the fact that we can now just use the same framework for both web applications and APIs. It's great to use the same Controller base class but fact remains that a Controller for an API has different needs in terms of functionality than a Controller for an MVC application that works with views. The ApiController attribute adds some great functionality to ASP.NET Core 2.1 controllers that makes life eas...

Scaling Out Your ASP.NET Core SignalR Application

Load balancers When you deploy your app to production at some point you'll want to scale out. Scaling out means running the app on multiple servers. When the app runs in the cloud scaling out is a matter of setting the number of servers you want to run. A mechanism called a load balancer will then pick a server on each incoming request. The load balancer can pick a different server in sequence or have some other logic going on to pick one. WebSockets When using web sockets there is no problem....

Retrieving a Secret from Azure KeyVault: Easiest Example Ever

The internet is full of code examples that try to show all possible features of Azure KeyVault. I felt the need for a very basic example just retrieving a secret. Here [https://github.com/RolandGuijt/rolandguijt.com-keyvault-sample] it is. It's an ASP.NET Core console application with a couple of added NuGet packages: * Microsoft.IdentityModel.Client.ActiveDirectory (for access token retrieval from Azure Active Directory (AAD) * Microsoft.Azure.KeyVault * Microsoft.Extensions.Configurat...

Using React's new context API

Why context? A component tree can quickly grow. The root component has many children, the children have many children and so on. What if you want to pass information that is considered global to a tree or subtree of components? For example what language these components should use. Or what the username is. You could use props of course, but it seems unnessary to pass on the same information over and over again to each component. This is where the context comes in. Pre context In this exampl...