Skip to content

Instantly share code, notes, and snippets.

View AaronSadlerUK's full-sized avatar

Aaron AaronSadlerUK

View GitHub Profile
@AaronSadlerUK
AaronSadlerUK / IntFriendlyMediaPickerValueConverter.cs
Created August 2, 2023 09:14
IntFriendlyMediaPickerValueConverter
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.PropertyEditors.ValueConverters;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Services;
public class IntFriendlyMediaPickerValueConverter : MediaPickerValueConverter
{
@AaronSadlerUK
AaronSadlerUK / default.aspx
Created December 14, 2022 16:56
Output Headers
<%@ Page Language="vb" %>
<html>
<head>
<title>Showing HTTP Headers via the Headers Collection in ASP.NET</title>
</head>
<body>
<%
Dim AllHttp As String
@AaronSadlerUK
AaronSadlerUK / Command
Created November 20, 2022 14:55
Auto update WMSVC Certificate after Win-Acme runs
.\wacs.exe --installation script --script "Scripts\ImportWMSVC.ps1" --scriptparameters "'{CertThumbprint}'" --certificatestore My
@AaronSadlerUK
AaronSadlerUK / IValidateYubiKeyOTPService.cs
Last active August 29, 2022 11:23
YubiKey OTP - Umbraco V10
public interface IValidateYubiKeyOTPService
{
Task<bool> ValidateYubiKey(string otp);
}
@AaronSadlerUK
AaronSadlerUK / WebPMiddleware.cs
Last active July 5, 2022 14:04
Dynamic WebP Images in Umbraco V10
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
public class WebPMiddleware
{
private readonly RequestDelegate _next;
@AaronSadlerUK
AaronSadlerUK / HeaderPolicyCollection.cs
Last active December 2, 2021 18:05
Configuring HTTP Security Headers In Umbraco V9
public static HeaderPolicyCollection GetHeaderPolicyCollection(bool isDev)
{
var policy = new HeaderPolicyCollection()
.AddFrameOptionsDeny()
.AddXssProtectionBlock()
.AddContentTypeOptionsNoSniff()
.AddReferrerPolicyStrictOriginWhenCrossOrigin()
.RemoveServerHeader()
.AddCrossOriginOpenerPolicy(builder =>
{
@AaronSadlerUK
AaronSadlerUK / ISiteMapXmlService.cs
Created October 13, 2021 09:55
How to create an Xml Sitemap in Umbraco V9
public interface ISiteMapXmlService
{
public string GenerateXml();
}
@AaronSadlerUK
AaronSadlerUK / ISyndicationXmlService.cs
Last active October 27, 2021 14:54
How to create an RSS & Atom feed in Umbraco V9
using System.ServiceModel.Syndication;
public interface ISyndicationXmlService
{
Atom10FeedFormatter GenerateAtomXml(string feedTitle, string feedDescription);
Rss20FeedFormatter GenerateRssXml(string feedTitle, string feedDescription);
}
@AaronSadlerUK
AaronSadlerUK / bundleconfig.json
Created October 6, 2021 20:18
How to use bundling and minification with Umbraco V9 (Part 2)
[
{
"outputFileName": "wwwroot/bundles/site.min.css",
"inputFiles": [
"wwwroot/lib/bootstrap/dist/css/bootstrap.css",
"wwwroot/css/site.css"
]
},
{
"outputFileName": "wwwroot/bundles/site.min.js",
@AaronSadlerUK
AaronSadlerUK / bundleconfig.json
Created October 6, 2021 18:40
How to use bundling and minification with Umbraco V9
[
{
"outputFileName": "wwwroot/css/site.min.css",
"inputFiles": [
"wwwroot/lib/bootstrap/dist/css/bootstrap.css",
"wwwroot/css/site.css"
]
},
{
"outputFileName": "wwwroot/js/site.min.js",