C# Archive

Prevent certain Optimizely visitor groups from being used in content areas

At my current client we had the need to prevent the use of certain visitor groups in some of the content areas. I.e. some areas were only to support national content, and other areas only regional content (where each region had a different visitor group). Here is a solution making use of ValidationAttribute. The visitor group ids are kept in the ContentAreaItem’s AllowedRoles property. The …

Using ActiveMQ with Optimizely 12

Whilst setting up Optimizely 12 to work with RabbitMQ is rather straight forward, making it use ActiveMQ for transport instead requires a bit more configuration on our part. Here is a short article on how to set up Optimizely 12 to use MassTransit (EPiServer.Events.MassTransit) with ActiveMQ. For a short instruction on how to set up a local ActiveMQ server, please see Muthu Kumaran‘s article on …

ActiveMQ connection tester application

While moving our client’s Optimizely 12 website to a new hosting provider we had to abandon our RabbitMQ installation in favour of a new ActiveMQ one, also supported by the on-prem event provider (EPiServer.Events.MassTransit). To make it easier setting this up I rewrote the old RabbitMQ connection tester application into a new one working with ActiveMQ. Source code and executable are available at GitHub. To …

RabbitMQ connection tester application

We set up Optimizely‘s new on-prem event provider (EPiServer.Events.MassTransit) for my current client’s Optimizely 12 website the other week. At current date it is still in beta until there are enough uses for there to be a production release. For the mass transit we set up RabbitMQ. For earlier Optimizely (Episerver) versions built on ASP.NET Framework there was a tool for testing the event replication …

Simple way to use enums for sorting in Optimizely Search & Navigation

As stated in the Optimizely Search & Navigation developer documentation on Sorting, “Sorting is supported for numerical types such as int, double, DateTime, and string”. This means that you will get an error from EPiServer.Find.SortingValidationHelper.ValidateSupportedType if you attempt to sort on an enum field. There are of course various solutions to this problem, but here is a rather simple one: turn the enum into a string …

Finding the latest Optimizely Search & Navigation’s client Javascript URL

I got a question on how to find the latest version of the Search & Navigation /epi-util/find.js script file after publishing the article Proxy for Optimizely Search & Navigation tracking script. It is really quite simple, if you look at how Optimiezely does things. The solution is to make use of the built-in IPathHelper (namespace EPiServer.Find.UI.Helpers). Optimizely’s default GetClientResourceBasePath implementation essentially makes a request to …

Proxy for Optimizely Search & Navigation tracking script

When using Optimizely Search & Navigation (previously Episerver Find) you will automatically get a reference to a client side Javascript injected into your markup. Occationally, you may want to proxy it via your Optimizely website’s backend, caching it or just make it appear as if it comes from your own domain. It may also be a way of avoiding false positives in regards to script …

Getting the root PageReference of the imported pages in Episerver

In our work to automate export and import of the production database into our test environment we had to maintain a test node in the Episerver page tree. This ment that we had to export it before replacing the database, and then import it again. Please see Exporting Episerver content programmatically through an ApiController and Importing Episerver content programmatically through an ApiController for information about …

Importing Episerver content programmatically through an ApiController

Importing the test node package that we exported earlier (see article Exporting Episerver content programmatically through an ApiController) would be the next step in our automated transfer of the production database to the testing environment. I extended our ApiController with an import endpoint for this purpose. Note that this code is never intended to be deployed to production. Importing is easier than exporting. The relevant …

Exporting Episerver content programmatically through an ApiController

As part of the automated transfer of the production database to the testing environment for my current client we found the need to maintain a node in the Episerver page tree that is used for testing. I extended our ApiController with an export endpoint for this purpose. Note that this code is never intended to be deployed to production. So the interesting part happens in …

Tracing between logs with a correlation ID

Attempting to match timestamps and whatnot to correlate requests over various logs may be quite tedious. Adding a correlation ID to your website makes this easier and may save you quite a bit of time. This is what we did at my current client for all of their Episerver websites. I Implemented this together with my collegue Svante Seleborg. Passing a correlation ID through your …

Different subsets of content types in different EPiServer multi sites with all types in one assembly

As I explained in my previous article Different subsets of properties in different EPiServer multi sites using same content type model my current client is building a common platform for 7 websites spread over 3 EPiServer installations. As the platform grew the need for restructuring grew as well. It was no longer viable to keep all content types in separate assemblies in order to add …

Different subsets of properties in different EPiServer multi sites using same content type model

For my current client we are building 7 websites spread over (at least) 3 EPiServer multi site installations. Rather than seeing each of them as separate entities, they all consume the same base code from a common platform (such as infrastructure, EPiServer content types, and so on). An issue that you’re facing when using the same block or page type on several EPiServer installations is …

EPiServer TinyMCE 3 Wrapping selection in unsupported aside tag

For my current client, we had a need to allow EPiServer editors to wrap XHtmlSting field content in aside tags in a user friendly manner. The first most obvious thought went to the styles drop down list and EPiServer’s editor.css file, however after a few tries and a bit of Ilspy‘ing I realized that the aside tag element is not supported by the current implementation. …

Assemblies not copied nor cleaned, and Visual Studio CS0006 Error when building

We were installing EPiServer Forms in a client’s EPiServer 9 website the other day, and encountered an issue with the binarier not being copied from the NuGet packages directory to the website’s bin folder. If we manually copied them there manually and then ran a Clean in Visual Studio, the EPiServer Forms assemblies would not be removed either. Also, if we tried adding references to …

Changing NLog minLevel LogLevel at runtime in EPiServer

We moved from log4net to NLog in my current client’s EPiServer 8.5 website last year (see Using NLog with EPiServer and log4net for more information). Some time ago we received a request about being able to alter the log level at runtime, without editing configuration files on the servers. Reasonable enough; we already had read access to the generated logs, but no way of temporarily …

Database persisted translations with edit tools for language file resources in globalized EPiServer websites

A few years back I wrote a small tool allowing web administrators to update EPiServer CMS 6 R2 language files by themselves without the help of their website developers. There were of course a few downsides to this, such as updated deployment procedures as not to lose any new translations. I took a few hours and made a new one for EPiServer 7.5 that works …

Sitemap.xml generator engine for Multi language EPiServer 7.5 websites

A sitemap.xml file is a useful tool for helping search engines to find relevant pages on your website. This sitemap generator engine for EPiServer is based on loose strategies supporting globalized multilingual content; in other words, mysite.se/sitemap.xml and mysite.no/sitemap.xml will return swedish and norwegian URLs respectively. The strategy based pattern allows for easy custom additions of any kind to the xml file; for instance, apart …