If you need to immediately know if the other end of your WebSocket has unexpectedly disconnected, this is a solution.
Author:Peter Morris
Detect if the other end of a TcpClient has disconnected
A simple but effective way of checking if the other end of a TcpClient socket has disconnected.
Stop customer firewalls blocking your Blazor WASM DLLs
Enterprise companies often have strict firewall rules that can block Blazor WASM apps from downloading their required DLLs.
Here is a simple fix!
Viewing Blazor auto-generated code
When you build an app with a .razor component in it, the compiler will auto-generate code to build the render tree. If you want to see the generated code you can edit your .csproj file and add the following to your <PropertyGroup> node. After you build your application, look in the obj folder that is …
Continue reading Viewing Blazor auto-generated code
Click to confirm
If you need a validation attribute on your input object that simply requires the user to tick a box to confirm something, you can use the following The class is then consumed like so This will work with any app that uses Data Annotations as a form of validation, such as ASP.NET MVC apps or …
Continue reading Click to confirm
Mocking Entity Framework Core DbSet
Entity Framework Core introduces various extensions to IQueryable to allow asynchronous operations.
It can be difficult to mock dependencies that use those extensions when writing tests.
This is how it’s done…
Tom Lehrer adds newly discovered elements to his song The Elements
After many decades of writing his famous song The Elements, I’ve inspired Tom Lehrer to add the newly discovered elements!
Entity Framework Core, SQL Server, and Deadlock victims
If you are seeing frequent deadlocks when inserting rows into a SQL Server table, here is the solution…
Generating globally unique mostly-sequential keys for DB rows across multiple processes
This article explains how you can generate GUID formatted values that are unique across processes and will also be appended to the end of SQL Server indexes.
Blazor: Scoping services to a component
Sometimes you need your component to have its own unique (isolated) dependency injection container, where all the injected services are disposed with the component.
This article explains how that can be done.