Skip to content

Instantly share code, notes, and snippets.

View nul800sebastiaan's full-sized avatar
🔥

Sebastiaan Janssen nul800sebastiaan

🔥
View GitHub Profile
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))]
@nul800sebastiaan
nul800sebastiaan / gist:c3459731791577582e38254fa6e0ccd6
Last active July 30, 2019 07:27
Example of catch-all route and added constraints
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))" });
@nul800sebastiaan
nul800sebastiaan / ShowOrderForm.cshtml
Last active July 15, 2019 01:05
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"))
using System;
using Umbraco.Core;
using Umbraco.Core.Services;
namespace My.Namespace
{
public class EventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
@nul800sebastiaan
nul800sebastiaan / gist:8641249
Last active December 24, 2018 09:53
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/)
// 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 November 9, 2018 13:21
Simple altTemplate RSS feed - see comments for usage instructions.
@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 / TicketOrderController.cs
Created February 9, 2015 16:09
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
{
<dependentAssembly>
<assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
public static Guid GetKey(this IPublishedContent content)
{
IPublishedContent um = content;
var wrapped = um as PublishedContentExtended;
while (wrapped != null)
wrapped = (um = wrapped.Unwrap()) as PublishedContentExtended;
var contentWithKey = um as IPublishedContentWithKey;
return contentWithKey == null ? Guid.Empty : contentWithKey.Key;
}
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory" from="info@test.com">
<network host="localhost" />
<specifiedPickupDirectory pickupDirectoryLocation="D:\Temp\Umbraco-CMS\src\Umbraco.Web.UI\App_Data\mail\" />
</smtp>
</mailSettings>
</system.net>