Skip to content

Instantly share code, notes, and snippets.

View naepalm's full-sized avatar

Janae Cram naepalm

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web.Http;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web;
using Umbraco.Web.WebApi;
@enkelmedia
enkelmedia / update examine fields.cs
Last active January 20, 2021 17:06
Update field in Lucene / Examine index (Umbraco 8 v8 -specific)
var index = (LuceneIndex)ExamineManager.Instance.Indexes.Where(f => f.Name == "ExternalIndex").FirstOrDefault();
// Get the IndexWriter
var writer = index.GetIndexWriter();
var searcher = (BaseLuceneSearcher)index.GetSearcher();
// perform search to get the doc from the index based on node id
Term term = new Term("id", "1082"); // Term to get node by id
var q = new TermQuery(term);
@dawoe
dawoe / DefaultController.cs
Created November 7, 2017 08:20
Donut Cache examples from Umbraco UK Festival talk "The need for speed"
public class DefaultController : RenderMvcController
{
[UmbracoDonutOutputCache(CacheProfile = "LongPageCache",
Options = OutputCacheOptions.NoCacheLookupForPosts &
OutputCacheOptions.ReplaceDonutsInChildActions, Order = 100)]
public override ActionResult Index(RenderModel model)
{
return base.Index(model);
}
}
@jamiepollock
jamiepollock / MyController.cs
Last active October 8, 2019 15:27
Umbraco XPath query with tokens
using System.Web.Mvc;
using Umbraco.Web.Models;
using Umbraco.Web;
using Umbraco.Core.Xml;
using Umbraco.Web.Mvc;
namespace MyWebsite.Controllers
{
public class MyController : RenderMvcController
{
@dampee
dampee / MediaExportController.cs
Created January 27, 2017 13:31
export media library (umbraco v6 + umbraco v7)
using System;
using System.IO;
using System.Web.Hosting;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.WebApi;
/// <summary>