# Umbraco gists worth stealing

> Three Umbraco gists: an Umbraco Forms workflow that posts entries as JSON to Power Automate or Zapier, a content finder that redirects legacy URLs, and a controller that protects media files on Umbraco Cloud.

Source: https://ali.id.au/blog/umbraco-gists/ (last edited 2026-10-17)

Three Umbraco jobs, three gists. None of them is a package: copy the file, change the constants, done.

## Send a form anywhere as JSON

[PostToUrlAsJson](https://gist.github.com/alirobe/220f59b486c4b0cd950d33712fa6d423) is an Umbraco Forms workflow that posts each entry to a URL as JSON, with an optional bearer token. Point it at a Power Automate or Zapier trigger and send the entry on to Dynamics 365, Salesforce or anything else.

- Put the file anywhere in the project and dependency injection picks it up. Not recompiling? Add it to `App_Code`.
- The payload carries the form's name and ID, the record ID, IP, member key, a UTC timestamp, and each field by its alias.
- It's written against the Umbraco 7 Forms API. MichelCollard's fork added fixes, merged in 2019.

## Keep old URLs alive

Moving a site to Umbraco breaks every old link. [This content finder](https://gist.github.com/alirobe/334f77d576a35d88e02f301916328005) runs on a 404, looks for a page whose legacy URL field matches the request, and redirects there.

- It ignores case, slashes, `.aspx` and `.htm`, so `/About-Us.aspx` finds `about-us`.
- It skips images and PDFs: "don't waste db search on asset requests".
- It sends a 302 to start. Switch to a 301 "for permanent/SEO purposes when you're more comfortable", because browsers cache those.
- It's Umbraco 7 code, adapted from [Warren Buckley's 404 handler](https://creativewebspecialist.co.uk/2013/08/07/the-new-way-to-do-a-404-umbraco-handler/).

Umbraco also keeps its own redirects whenever a page is renamed or moved. To take them into SEOChecker, [this query](https://gist.github.com/alirobe/a8de71c875a6c089cce0d7781897e2fb) exports them: run it in SSMS, save the results as CSV, import the CSV. Replace `1075` with your root node ID first.

## Lock down media on Umbraco Cloud

Public access protects pages, not the files in `/media`: anyone with the link gets the PDF. [This controller](https://gist.github.com/alirobe/2595fbe2d5d5fc1ef2f181d2ca18ec1f) serves media through `/secure/` and checks the member before it hands the file over. It's Giacomo De Liberali's [approach](https://giacomodeliberali.com/blog/umbraco-protect-media-items), reworked for Umbraco 9 on Umbraco Cloud.

- A rewrite rule sends every `/media` request to `/secure`. I had trouble hijacking `/media` on Umbraco Cloud, "probably due to my own ignorance", so I went round it.
- Turn off Umbraco Cloud's CDN cache. Otherwise, I think, Cloudflare handles media requests before your code sees them.
- The role check is marked untested in the gist. Test it before you trust it.

Also in the drawer: [a media folder browser macro](https://gist.github.com/alirobe/2a0d27ad7da455710bc8) for Umbraco 7, fine up to about 100 files.

