Skip to content

Instantly share code, notes, and snippets.

View davecluderay's full-sized avatar

Dave Cluderay davecluderay

  • UK
View GitHub Profile
@davecluderay
davecluderay / PathBaseRegistration.cs
Last active April 4, 2025 21:38
Register startup filter to insert PathBase middleware at the earliest opportunity
using Microsoft.Extensions.Options;
internal sealed class PathBaseSettings
{
/// <summary>
/// The path prefix, if any, which will be stripped from the request path and added to the request path base.
/// During development, this might be empty, but then set when the application is deployed behind a reverse proxy.
/// Example: "/my-api"
/// </summary>
public string PathBase { get; set; } = string.Empty;
@davecluderay
davecluderay / ShellLink.cs
Created March 17, 2015 14:54
Resolves shell links
@davecluderay
davecluderay / KilnUrlHandler.cs
Last active August 29, 2015 14:04
Handles kiln:// URLs, translating them into the full http(s) form before executing them.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
@davecluderay
davecluderay / PublicKeyToken.cs
Created July 4, 2014 13:34
Generate a public key token from an X.509 certificate (for use in ClickOnce manifests).
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
public static class PublicKeyToken
{
public static string FromCertificate(X509Certificate cert)
{
var publicKeyBlob = GetCspPublicKeyBlob(cert);