Protect your ASP.NET site using Passkey's via the Passwordless service
21 Mar 2024
WebAuthn is a new standard to authenticate users in a secure way by making use of passkeys. Lets explore how to protect your ASP.Net site using WebAuthn via Bitwarden's Passwordless service.
WebAuthn is a relatively new standard for authenticating users and is an incredibly secure way to authenticate users by being phishing resistant, and not requiring passwords at all. It accomplishes this via public-key cryptography. To read more about it, check out
Wikipedia. You can also see which services already support passkeys
here.
Protect your ASP.NET site using Supabase authentication
20 Feb 2024
Sometimes you still want to build a simple server side rendered website, and you want to use simple cookie based auth. Let's explore how we can leverage Supabase Auth to protect our site.
Now that the pendulum is slowly swinging back towards classic plain HTML web servers, we can also simplify our authentication strategies. It's time to go old school again, and build a plain old ASP.NET MVC site using server side razor as our view engine. It's going to contain a very basic set of pages, and navigation links that change based on whether the user is logged in or not. We're going to use
Supabase Auth to handle all the actual identity management, as well as providing us with the E-Mail verification functionality.
HTMX, WebSockets, SignalR and you
31 Dec 2023
HTMX has gained some recent popularity. Lets explore how we can consume a SignalR Hub from a HTMX application.
Derailing gracefully with Railway Oriented Programming
28 Aug 2023
Railway oriented programming is a great way to compose multiple functions that can each fail for a different reason. Here we're going to explore some techniques on how to model the Error state.
When learning F#, at some point you'll come across the concept of Railway Oriented Programming (ROP). It's primarily a technique used for error handling and helps alleviate some of the struggles of using only exceptions. The main advantage is that possible error cases are encoded in the type system, which requires you to explicitly handle the possible errors instead of encountering an unexpected exception at runtime. Scott Wlaschin has a
great post introducing the concept and use cases of ROP. This is a great read if you're unfamiliar with this style of programming.
F# in strange places: Supabase edge functions
31 Dec 2022
With the rising interest in WebAssembly, can we compile F# to WebAssembly, but then use it from a Supabase edge function?
Let's write Fable bindings for a JS library
02 Feb 2022
Learn about writing Fable Bindings for a Javascript or Typescript library. See the article for a list of common scenarios and examples.
Writing fable bindings is easier than many people think it is, but still require a time investment depending on how much of the API of a Javascript/Typescript library you want to expose. Having a Typescript definitions file will give you a very big advantage as you can see exactly what types a function expects and returns, without implementation details getting in the way. Additionally, there is the
ts2fable project, which attempts to automagically type out everything in the definitions file. This is usually a good starting point. The official
fable documentation is a good resource, and one of the resources I used to learn how to write bindings.
Using Sutil to develop a real world application
31 Dec 2021
Testing out a new web framework is always difficult unless you spend some time with it building a real world application. This post explores doing just that by using Sutil to develop an application called Conduit as part of the Real World project to compare frontend and backend frameworks.
Managing your client connections in SignalR, including with authentication
09 Jul 2021
When using SignalR, one of the most important things will be to manage the various connections made by the clients, as well as being able to send messages to specific clients. SignalR offers three different ways of specifying connections and clients, each with their distinct usages. The question comes down when to use what, and the advantages and disadvantages offered by each.
Although this post is written with a focus on using F# and Fable.SignalR, the concepts talked about are applicable to SignalR in general, including when used with C#
Improving Real-time communication using Fable.SignalR
31 Dec 2020
Learn to use Fable.SignalR for a more functional and type-safe approach to communication over websockets when using Fabulous.Xamarin as the client.
This is a continuation of my previous blog post about
real-time communication with Giraffe and Fabulous. Reading the other article is not required for this one, as it aims to accomplish the same thing, but using a nice friendly F# wrapper around SignalR. This post is also my entry for the
F# advent calendar organized by Sergey Tihon. Once again a huge thanks to Sergey for organizing these every year. Awkwardly, Mark Allibone has also
written an article for the advent calendar, which is very similar to my first post. Well, here's hoping we can learn something from each other.
Real-time communication with Giraffe and Fabulous
25 Oct 2020
Learn how to integrate SignalR with Fabulous to give your xamarin apps written in F# real-time interactivity.
Real-time communication can make any application that much more interactive. Whether it be a simple chat application, or other notifications that are pushed live to the client, there is a significant improvement in the user experience when this information is pushed in real-time to the client without the need for a page refresh, or specifically having to pull this data. In many user facing applications, this is usually accomplished using WebSocket protocol. And in the .Net space, the dominant library for WebSocket support is
SignalR. SignalR provides a number of advantages over directly using WebSockets, because it provides several features on top. Some of these features include improved connection management (e.g. how to handle reconnecting), sending messages to all or only some clients, and built-in scaling. Additionally, SignalR can automatically fallback to Server-sent events or Long-Polling depending on what the client supports.
Test your UI by treating it as a state machine
01 Jul 2020
I want to introduce a state machine testing library for .Net called [Scrutiny](https://github.com/kaeedo/Scrutiny/). You can get it from [NuGet here](https://www.nuget.org/packages/Scrutiny/). It aims to allow random testing of state machines, with a focus on UI testing, by modeling a state machine as a directed graph and path finding through all possible states.
I want to introduce a state machine testing library for .Net called
Scrutiny. You can get it from
NuGet here. It aims to allow random testing of state machines, with a focus on UI testing, by modeling a state machine as a directed graph and path finding through all possible states.
My experience with the F# Mentorship program
30 Apr 2020
A summary of my experience as a mentor in the F# mentorship program.
The Winter 2020 round of the
F# mentorship program is now over. I participated as a mentor, and wanted to share my experience. The mentorship program is organized by the
F# Software Foundation, and runs twice a year for 6 weeks at a time. All participants are volunteers of the community, and are asked to join the F# slack channel to communicate.
Type safe SQL Queries using Rezoom.SQL
15 Dec 2019
Introduction to Rezoom.SQL. A F# Type Provider that generates types from migration scripts, instead of a remote resource.
This is my
F# Advent Calendar 2019 entry. Last year I wrote about
Fable React and Preact, but this year I want to write about data access, a topic that practically any application requires. Considering F# is a .Net language, any of the large amount of ORMs available to C# are also available to F#. The big problem, of course, is that they are generally OOP oriented and not not very idiomatic F#. Now, of course you could argue that, because F# is multi-paradigm, it's not actually a problem switching to OOP, but where would the fun be in that?
Recursively replacing parts of a URL
09 Apr 2019
One approach to learning how to write idiomatic F# is by first writing in an iperative style, and then refactoring it.
I’m slowly building a .Net Core global tool to do some REST API testing. One idea I had for this project was to be able to generate multiple URLs with different variables. e.g. http://www.example.com/?id={{INT}}
would generate several URLs with the {{INT}}
part replaced with randomly generated integers. The solution that I came up with for this, was to use regular expressions. {{(.*?)}}
is the regex I came up with to find all parts enclosed by double brackets.
Fable React is nice. But what about Fable Preact
31 Dec 2018
Reducing final bundle size of a Fable-React application by using Preact instead.
This is my entry for the
F# Advent Calendar 2018. I’ve been doing full-stack .Net web development for ~6 years now, and I learned F# ~3 years ago. In the second set of 3 years, I’ve also done more frontend web development than I did backend. In this time I’ve had the (mis)fortune of playing with countless JS SPA frameworks. This has given me the insight into what these various frameworks do, how they work, and how they differ from the other frameworks. I’ve also thought about what web developers should be paying more attention to, and what is nice and fun. In this post I want to explore a combination of what’s fun (Fable Elmish), and what I believe developers need to pay more attention to (bundle size). With that, I’d like to delve into two topics, namely, what I believe to be a big problem with the current state of web development, and a possible solution to this problem.
User Defined Function in SQLite
17 Nov 2018
Extending SQLite with a User Defined Function to workaround SQLite's ASCII limitation when it comes to comparing diacritics.
I ran into an interesting problem recently. The task was to search for something within a SQLite database by comparing strings. Generally very easy to do in just SQL using the UPPER function:
Recursive Async
15 Nov 2018
More involved take on recursion. How to properly type recursion when async is involved.
There was recently a project I was working on that required a recursive call. The problem was, that the function returned an async workflow, and in my inexperience, I was running into the problem that I didn’t know what each exit point should return exactly. This is a problem, because in F# all code paths must return the same type, and I wasn’t sure when I needed to wait for an async call, or return the async workflow itself. The idea behind the function was that it would query the database for a specific string, and if it didn’t find anything, it would shorten the string and try again, until the string was a certain length. After some looking around online, I came across
this FSSnip that describes a recusive async function:
Power of Active Patterns
11 Nov 2018
Showcase about how one could refactor a large set of nested if/else statements by using F# Active Patterns
I’ve been working on a
dotnet core global tool. One of the things that such a tool has, is many command line options. I found Argu to parse these command line options. However I ran into the problem that I was left with a very large amount of if/else statements. Perhaps I don’t know what the “proper” way is of handling this, but this was my naive approach.