<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><language>en</language><title>Blog posts by Mathias Kunto's blog</title> <link>https://world.optimizely.com/blogs/Mathias-Kuntos-blog/</link><description></description><ttl>60</ttl><generator>Optimizely World</generator><item> <title>Injecting Fragments in Optimizely XHtmlStrings</title>            <link>https://blog.mathiaskunto.com/?p=4367</link>            <description>Injecting fragments in Optimizely XHtmlStrings is quite easy using a custom display template to render the property. Here is an example on how you can inject custom data based on Optimizely blocks dropped in the XHtmlString property. I&amp;#8217;ve been using an approach similar to this to inject ids used for anchor tag navigation also within free text. The interesting thing in the custom display template is the call to the inject fragments method. In the InjectFragments method, we will create a new XhtmlString object containing our manipulated fragments. As we are working with blocks dropped in the XhtmlString by the </description>            <guid>https://blog.mathiaskunto.com/?p=4367</guid>            <pubDate>Mon, 24 Jun 2024 19:43:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Clearing output cache in a multi server environment</title>            <link>https://blog.mathiaskunto.com/?p=4229</link>            <description>This is a follow up to the previous Acting on Optimizely Remote Events article. While still working with the older Optimizely 11 you may rely on the Remote Event functionality to clear cache. However, in some cases you may need to build on this functionality to clear the output cache on other servers manually. In a previous project we used this to clear the cache of virtual pages (i.e. we had a single Optimizely page instance which presented different information based on a custom id number, together with a friendly URL rewriting functionality). This first method is to be called </description>            <guid>https://blog.mathiaskunto.com/?p=4229</guid>            <pubDate>Sat, 25 May 2024 17:17:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Prevent certain Optimizely visitor groups from being used in content areas</title>            <link>https://blog.mathiaskunto.com/?p=4238</link>            <description>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&amp;#8217;s AllowedRoles property. The attribute may be used on any ContentArea property as below. Of course, allowing or disallowing both national and regional content at the same time makes no sense.</description>            <guid>https://blog.mathiaskunto.com/?p=4238</guid>            <pubDate>Sat, 14 Oct 2023 16:03:15 GMT</pubDate>           <category>Blog post</category></item><item> <title>System.Data.SqlClient.SqlException: Invalid column name ‘IsApproved’, ‘IsLockedOut’, ‘Comment’, ‘CreationDate’, ‘LastLoginDate’, ‘LastLockoutDate’</title>            <link>https://blog.mathiaskunto.com/?p=4223</link>            <description>Got this SqlException again moving a database from a client&amp;#8217;s production environment into development. Thought I&amp;#8217;d write a short note on resolving it. Check the migration history table: It is likely that the initial create of the tables used Microsoft.AspNet.Identity.EntityFramework.IdentityUser instead of the expected EPiServer.Cms.UI.AspNetIdentity.ApplicationUser. The ContextKey column would contain EPiServer.Cms.UI.AspNetIdentity.ApplicationDbContext`1  rather than EPiServer.Cms.UI.AspNetIdentity.ApplicationDbContext`1 . This may be resolved by removing the tables dbo.__MigrationHistory (or just the row with the identity migration if there are others), dbo.AspNetUserClaims, dbo.AspNetUserLogins, dbo.AspNetUserRoles, dbo.AspNetRoles, dbo.AspNetUsers. Then restarting the Optimizely application and attempting to login to the admin/edit interface. Of course, any data in </description>            <guid>https://blog.mathiaskunto.com/?p=4223</guid>            <pubDate>Sat, 17 Jun 2023 21:36:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Acting on Optimizely Remote Events</title>            <link>https://blog.mathiaskunto.com/?p=4227</link>            <description>Just a short piece on how to act on Optimizely&amp;#8216;s remote events. While in later versions you may use for instance RabbitMQ or ActiveMQ, still being on 11 will have you using the older event distribution. For attaching your own handlers to the received event, you will need to get an instance of the IEventProviderAccessor rather than accessing events directly like with publish events via IContentEvents. Optimizely have plenty of their own events, so you&amp;#8217;ll need to filter on what you&amp;#8217;re interested in.</description>            <guid>https://blog.mathiaskunto.com/?p=4227</guid>            <pubDate>Sat, 20 May 2023 11:37:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Using ActiveMQ with Optimizely 12</title>            <link>https://blog.mathiaskunto.com/?p=4205</link>            <description>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&amp;#8216;s article on How to use ActiveMQ in C#. Settings up Optimizely to use ActiveMQ requires a bit of settings. Here is an example on what you can add to your appsettings.Development.json. Since Optimizely will be setting up </description>            <guid>https://blog.mathiaskunto.com/?p=4205</guid>            <pubDate>Thu, 16 Mar 2023 20:58:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>ActiveMQ tester application with topic support</title>            <link>https://blog.mathiaskunto.com/?p=4199</link>            <description>I&amp;#8217;ve updated the ActiveMQ tester application with topic support as it is required by the Optimizely on-prem event provider (EPiServer.Events.MassTransit). Otherwise, the usage is as before (see ActiveMQ connection tester application). Source code at GitHub.</description>            <guid>https://blog.mathiaskunto.com/?p=4199</guid>            <pubDate>Thu, 16 Mar 2023 11:15:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>ActiveMQ connection tester application</title>            <link>https://blog.mathiaskunto.com/?p=4197</link>            <description>While moving our client&amp;#8217;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 use you will have to update appsettings.json with proper values. The sender may be started in a command prompt by typing: and the receiver:</description>            <guid>https://blog.mathiaskunto.com/?p=4197</guid>            <pubDate>Fri, 10 Jun 2022 17:24:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Episerver Remote Events tester console application for framework 4.8 and Optimizely 11</title>            <link>https://blog.mathiaskunto.com/?p=4194</link>            <description>My current client is moving their Optimizely 11 websites to a new hosting provider and we need an easy way to test the remote event replication system. I remember that there was an old console application for this back in the day, but when I found a copy of it I realized that it required .net 2.0 to function. I shamelessly disassembled the application and stole the code (I can&amp;#8217;t find out who created it though, sorry) in order to upgrade it a bit. Here is a quick version made for .net framework 4.8 and the Optimizely 11 assemblies. I&amp;#8217;m </description>            <guid>https://blog.mathiaskunto.com/?p=4194</guid>            <pubDate>Sat, 28 May 2022 10:40:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>RabbitMQ connection tester application</title>            <link>https://blog.mathiaskunto.com/?p=4180</link>            <description>We set up Optimizely&amp;#8216;s new on-prem event provider (EPiServer.Events.MassTransit) for my current client&amp;#8217;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 between servers. I couldn&amp;#8217;t find anything similar for helping us test the RabbitMQ set up, so I created a simple console application for this. Source code and the executable are available at GitHub. To use, </description>            <guid>https://blog.mathiaskunto.com/?p=4180</guid>            <pubDate>Sun, 20 Feb 2022 14:43:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Simple way to use enums for sorting in Optimizely Search &amp; Navigation</title>            <link>https://blog.mathiaskunto.com/?p=4160</link>            <description>As stated in the Optimizely Search &amp;#38; Navigation developer documentation on Sorting, &amp;#8220;Sorting is supported for numerical types such as int,&#160;double, DateTime, and string&amp;#8221;. 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 and use that for sorting instead. TheEnumString will be calculated when Optimizely Search &amp;#38; Navigation index the page. A simple method call like this in a getter is OK. However, if you start doing more </description>            <guid>https://blog.mathiaskunto.com/?p=4160</guid>            <pubDate>Sat, 12 Feb 2022 09:57:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Finding the latest Optimizely Search &amp; Navigation’s client Javascript URL</title>            <link>https://blog.mathiaskunto.com/?p=4150</link>            <description>I got a question on how to find the latest version of the Search &amp;#38; Navigation /epi-util/find.js script file after publishing the article Proxy for Optimizely Search &amp;#38; 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&amp;#8217;s default GetClientResourceBasePath implementation essentially makes a request to https://dl.episerver.net/version.json which just returns the current version.</description>            <guid>https://blog.mathiaskunto.com/?p=4150</guid>            <pubDate>Sun, 06 Feb 2022 08:15:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Proxy for Optimizely Search &amp; Navigation tracking script</title>            <link>https://blog.mathiaskunto.com/?p=4132</link>            <description>When using Optimizely Search &amp;#38; 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&amp;#8217;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 tags not using Subresource Integrity (SRI) hashes where you control the script location yourself. The ExternalResourceService is just a simple disposable class making the call to retireve the client side script, then returning it as </description>            <guid>https://blog.mathiaskunto.com/?p=4132</guid>            <pubDate>Thu, 03 Feb 2022 17:18:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Getting the root PageReference of the imported pages in Episerver</title>            <link>https://blog.mathiaskunto.com/?p=4113</link>            <description>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 this. In order for our export functionality to know the node to export, we had to maintain information about its whereabouts. We keep this data stored in a PageReference property on our settings page. However, </description>            <guid>https://blog.mathiaskunto.com/?p=4113</guid>            <pubDate>Mon, 19 Apr 2021 19:16:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Importing Episerver content programmatically through an ApiController</title>            <link>https://blog.mathiaskunto.com/?p=4104</link>            <description>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 Episerver interface IDataImporter is not disposable. We will still use the ServiceLocator to get an instance as the default implementation may cause issues if we were to reuse it in our singleton ImportExportService. There are </description>            <guid>https://blog.mathiaskunto.com/?p=4104</guid>            <pubDate>Sun, 18 Apr 2021 07:58:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Exporting Episerver content programmatically through an ApiController</title>            <link>https://blog.mathiaskunto.com/?p=4084</link>            <description>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 the onStreamAvailable Action in the PushStreamContent constructor. In the ExportTestNode method below, the outputStream is the one provided through the Action. This stream is Write only. The Episerver export functionality on the other hand requires </description>            <guid>https://blog.mathiaskunto.com/?p=4084</guid>            <pubDate>Sat, 17 Apr 2021 16:57:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Tracing between logs with a correlation ID</title>            <link>https://blog.mathiaskunto.com/?p=4057</link>            <description>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 application We want to set up a correlation ID early in the request cycle so that we are able to use it throughout our entire application. This may be done in a HttpModule. I have </description>            <guid>https://blog.mathiaskunto.com/?p=4057</guid>            <pubDate>Sat, 03 Apr 2021 07:43:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Episerver upgrade: Could not find a part of the path {wwwroot}\ClientResources\ClientResources\packages.config.</title>            <link>https://blog.mathiaskunto.com/?p=4052</link>            <description>Just a short note on an exception I got after upgrading the Episerver NuGet packages on a few of my client&amp;#8217;s websites. All of them worked perfectly, except the one that gave me the following message: It is the package.config inside the Shell.zip that it&amp;#8217;s looking for. It turns out that the package installation had removed a few lines from the configuration file.</description>            <guid>https://blog.mathiaskunto.com/?p=4052</guid>            <pubDate>Sat, 20 Mar 2021 14:46:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Enriching your exceptions with information from Episerver</title>            <link>https://blog.mathiaskunto.com/?p=4043</link>            <description>Adding custom information along with the usual message and stacktrace in your exceptions may possibly make it easier to find out what&amp;#8217;s happening in your Episerver website. Here is a bit of code showing how it may be done in a quite simple way. I created it some time back and it has since then been improved by my collegues Svante Seleborg and Martin Lindstr&#246;m. I&amp;#8217;ve altered it a bit to make it easier to follow. The Enrich extension method below will need to suppress any exceptions being thrown by the Enrich functionality itself as throwing exceptions while handling exceptions </description>            <guid>https://blog.mathiaskunto.com/?p=4043</guid>            <pubDate>Sat, 06 Mar 2021 16:07:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Passing data between your own ContentSecuritySaving and ContentSecuritySaved event handlers in Episerver</title>            <link>https://blog.mathiaskunto.com/?p=4038</link>            <description>If you want to pass information between a PublishingContent handler and a PublishedContent handler (EPiServer.Core.IContentEvents) it is quite easy as the internal code provides you with a Dictionary property on the ContentEventArgs object. This may be useful if you need to maintain information about a property value through an entire publishing process. I.e. find out if the editor changed the value of the property. So, this is all good, but what about when someone changes access rights on one or more pages in the edit or admin modes? There is an interface with events for that as well (IContentSecurityRepository), but </description>            <guid>https://blog.mathiaskunto.com/?p=4038</guid>            <pubDate>Thu, 11 Feb 2021 20:29:00 GMT</pubDate>           <category>Blog post</category></item></channel>
</rss>