Skip to content

Instantly share code, notes, and snippets.

Sebastiaan Janssen nul800sebastiaan

Block or report user

Report or block nul800sebastiaan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:0aa1fc02911604bf11eeb4a5c15b7d51
using System.Web.Routing;
using Umbraco.Core.Composing;
using Umbraco.Web.Runtime;
namespace RemoveRoutes
{
// This is required to ensure this composer runs after
// Umbraco's WebFinalComposer which is the component
// that creates all of the routes during startup
[ComposeAfter(typeof(WebFinalComposer))]
View gist:927dcf155439fcc867e97a4d8dda6e16
using System.Web.Routing;
using Umbraco.Core;
namespace RemoveRoutes
{
public class RemoveRoutesStartupHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
// Reference: https://github.com/umbraco/Umbraco-CMS/issues/5206
@nul800sebastiaan
nul800sebastiaan / gist:c3459731791577582e38254fa6e0ccd6
Last active Jul 30, 2019
Example of catch-all route and added constraints
View gist:c3459731791577582e38254fa6e0ccd6
RouteTable.Routes.MapRoute("Default", "{controller}/{action}/{id}",
//Defaults
new { controller = "Home", action = "Index", id = "" },
//Constraints (controller cannot start with UmbProfile, UmbRegister, UmbLogin, UmbLoginStatus or Tags)
new { controller = "^(?!(UmbProfile|UmbRegister|UmbLogin|UmbLoginStatus|Tags))" });
View ShowOrderForm.cshtml
@using Awesome.FormDemo.Controllers
@model Awesome.FormDemo.Models.TicketOrderModel
@if (TempData.ContainsKey("CustomMessage"))
{
<div>Hooray! - @TempData["CustomMessage"]</div>
}
else
{
using (Html.BeginUmbracoForm<TicketOrderController>("FormSubmit"))
View SetMediaNameToFilename
using System;
using Umbraco.Core;
using Umbraco.Core.Services;
namespace My.Namespace
{
public class EventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
View LetsEncrypt.ps1
Import-Module -Name D:\Temp\ACME-posh\ACMEPowerShell.psd1
$domain = "mydomain.com"
$certificiatePassword = "abcd1234"
$email = "letsencrypt@mydomain.com"
$vault = "D:\Vault\{0}\{1}" -f $domain, [guid]::NewGuid()
mkdir $vault
cd $vault
Initialize-ACMEVault -BaseURI https://acme-v01.api.letsencrypt.org/
New-ACMERegistration -Contacts mailto:$email
@nul800sebastiaan
nul800sebastiaan / gist:8641249
Last active Dec 24, 2018
What's this Umbraco route hijacking all about? (more info in this blog post: http://cultiv.nl/blog/whats-this-umbraco-route-hijacking-all-about/)
View gist:8641249
// MODEL
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.Models;
namespace Cultiv.Models
{
public class BlogOverview : RenderModel
@nul800sebastiaan
nul800sebastiaan / Rss.cshtml
Last active Nov 9, 2018
Simple altTemplate RSS feed - see comments for usage instructions.
View Rss.cshtml
@inherits UmbracoTemplatePage
@{
Response.ContentType = "text/xml";
// The variables in this code block are the only ones you might need to change a little to get it to work
var blogName = "Cultiv";
var currentUrl = string.Format("https://{0}", Request.Url.Host);
// Find first node under the root of document type BlogOverview
var blogNode = Model.Content.AncestorOrSelf(1).Descendants("BlogOverview").First();
@nul800sebastiaan
nul800sebastiaan / gist:1067257
Created Jul 6, 2011
Grouping in Razor (Umbraco 4.7.1)
View gist:1067257
@foreach(var group in Model.Children.InGroupsOf(2))
{
<div class="row-of-two">
@foreach(var item in group)
{
<span>@item.Name</span>
}
</div>
}
View TicketOrderController.cs
using System;
using System.Linq;
using System.Web.Mvc;
using Umbraco.Course.Models;
using Umbraco.Web.Mvc;
namespace Awesome.FormDemo.Controllers
{
public class TicketOrderController : SurfaceController
{
You can’t perform that action at this time.