Skip to main content

Posts

Showing posts from March, 2025

Umbraco Tip: How to enable Umbraco redirect tracking for a specific document type

Recently, I was working on an Umbraco case with my colleague, Harry Buxton, and the issue was that even though we were updating the names of certain content pages, the links to those pages were not updated correctly. As a result, we couldn't access those pages on the front end. Furthermore, they were not visible in the "Redirect URL Management" dashboard either.  Problem Umbraco CMS has a built-in URL Redirect Management feature for routing and URL tracking. Whenever a document is published, and this causes changes to its URL (and any of its decendants' URLs), Umbraco makes a note of the old URLs and whenever an incoming request is served and the default content finders cannot find a matching published document, Umbraco checked whether the URL matches on of these saved URLs. If a match is found, Umbraco returns a "301 Redirect" response pointing to the new URL of the document.  The issue was that this was not happening with our content pages; after updating...

Umbraco Tip: How to securely fix "SurfaceController POST not allowed outside Umbraco due to missing antiforgery token"

Today, I was working on a v8 to v13 upgrade project, and I realised that I couldn't access my [HttpPost] actions in a SurfaceController from an Ajax POST call. After trying some solutions without any luck, including Route attributes to the SurfaceController and actions, I found out that starting from Umbraco v9, the SurfaceControllers have the anti-forgery check by default as SurfaceControllers are primarily made for POSTing forms within Umbraco.  To resolve this issue, I added the following  beforeSend bit to my Ajax call and also added the [ValidateAntiForgeryToken] attribute to my actions in my SurfaceController. During tests, I also realised that I could ignore the anti-forgery token completely by adding the [IgnoreAntiforgeryToken] attribute to my actions, but this is not an option that anybody should go for as this option skips the anti-forgery token validation and makes your website more vulnerable for things like Cross-site request forgery attacks.   $ . ajax...