Skip to main content

Posts

Showing posts from 2017

Creating a dynamic, multi-source, search enabled TreeList for Sitecore

I spent a partially frustrating but ultimately reasonably successful day recently looking to extend a Sitecore editorial control to add some functionality that would be of benefit to our editors. Our starting point was the built in TreeList control that we were using to allow editors to select images for a carousel. With this we can set a source to limit the selections to an appropriate location in the media library tree. That did the job for the initial release of the feature but we then had to handle some additional requirements, as follows. We need to allow editors to select from two locations, not just one. Specifically they were selecting images for display on a page on a house-builder's website, with the page showing a house that's of a particular type and found on a particular site. So images for the site and the house type were appropriate, and these were stored in different folders. We needed to dynamically set the source of these locations, so they were pic...

FakeDb, Layout tests and Sitecore 9

Following the previous post on this blog involving an issue we ran into upgrading a Sitecore project from 8.2 to 9, this one is also on the same subject. The issue this time was some unit tests that make use of the FakeDb  library began to fail following the upgrade. Noticing that it was just tests that involved checking the status of layout related fields, with the help of some de-compilation, it was clear that a change had occurred in the Sitecore.Data.Fields.LayoutField.GetFieldValue method that now involve the use of a pipeline components. I found it was possible to resolve this by adding the following to the app.config file, within the &lgt;sitecore&ggt; element, for the test projects containing the failing tests: <pipelines> <getLayoutSourceFields> <processor type="Sitecore.Pipelines.GetLayoutSourceFields.GetFinalLayoutField, Sitecore.Kernel" /> <processor type="Sitecore.Pipelines.GetLayoutSourceFiel...

Unit testing HttpRequestArgs with Sitecore 9

Working on a project currently with Sitecore CMS, which is currently undergoing an upgrade to version 9. We had this piece of code, used in the context of unit testing classes that inherit from HttpRequestProcessor , such as custom page resolvers. To use these classes you override a method Process() that takes an instance of HttpRequestArgs . Constructing these classes from a unit test isn't straightforward and up to now had relied on a method detailed by James-West Sadler on his blog here . public static HttpRequestArgs CreateHttpRequestArgs(string url) { var httpRequest = new HttpRequest(string.Empty, url, string.Empty); var httpResponse = new HttpResponse(new StringWriter()); var httpContext = new HttpContext(httpRequest, httpResponse); var requestArgs = new HttpRequestArgs(new HttpContextWrapper(httpContext), HttpRequestType.End); // Reflection used to call the private Initialize method on the HttpRequestArgs obj...

Let's Encrypt on Azure Web Apps - Key Expiration Issue

I run a side-project website on Azure PaaS, for a music library business called The Perfect Music Library . For a year or so this has had an SSL certificate provided by Let's Encrypt . The certificates provided for this service expiry relatively quickly, and so in order to keep this updated I've set up and deployed a site extension and web job using the excellent instructions provided by Nik Molnar. Recently though I noticed that the most recent update had failed which meant browser warnings of an outdated certificate were being seen by visitors that attempted to access the site. It turns out the issue was a key that's created as a process of setting up a "service principal" (step 5 of instructions linked above) had expired after a year or so. To diagnose this I opened up the Azure portal, located the web application in question and navigated to the list of web jobs. Within that, right-clicking on the letsencrypt.siteextension.job allows the view of the...

Gotcha with Updating .Net Core Using VS.Net 2017

A little while back I put together a very basic ASP.Net Core application and blogged about my first impressions in transitioning from "classic" ASP.Net - can we call it that now?! - here . Just today thought would be a good idea to update it to the latest version, particular the change in the format of the project file from JSON (project.json) to XML (.csproj). With VS.Net 2017 this was very straightforward, but I found one gotcha that may or may not affect others, so thought would record it here. When opening the project - originally created in VS.Net 2015 - in VS.Net 2017 a message comes up saying a one-way update needs to happen. I let that complete and it ran successfully. Unfortunately after that VS.Net froze. Closing and restarting the application a few times didn't seem to help - after a few seconds the IDE became unusable and had to be stopped using Task Manager. The issue seemed to be with a hidden .vs folder that VS.Net creates, containing various de...

Extending Azure AD B2C with Custom Application Permissions

I recently had chance to work on a proof of concept using Azure AD B2C, which didn't in the end progress but was worth a write-up in case others are working on similar projects, or of course it's something I need to refer back to in future. Azure AD B2C provides cloud based identity and access management with a consumer focus, supporting social media logins and allowing for controlled access to business to consumer applications. The particular challenge I looked at followed a recognition that a given client may have several applications that require authentication and authorisation services, but each of them will have their own specific detail around these aspects. Azure AD B2C offers a model of user accounts and groups, however this generic structure may not provide sufficient detail and flexibility for all applications that want to use it. The proof of concept worked up then was to provide features to extend Azure AD B2C, by building an API that applications can call ...

Machine learning with F#

Another cross-post to something I've put together on my company's Medium site - in this article I'm discussing working with F# and decision trees (both new to me), in a what was an enjoyable, but futile, attempt to draw some insights from a data set of horse racing results. You can read the article here .

Umbraco Show & Tell London

Recently had the pleasure of speaking with my colleague Ben Pilgrim at the Umbraco "Show & Tell" event in London. The theme of the day was the "great Umbraco editorial experience". There's a nice write-up of the day up on the Umbraco blog and we've made the slides available here .