Mathias Kunto Archive

EPiServer Forms: Adding custom server side validation to form fields (Luhn algorithm)

When you’re adding custom EPiServer Forms field blocks to your solution, you occasionally have the need for adding custom validation as well. Here is a sample of how to add a custom server side validation to your textfield block; you will probably also need client side validation for this, please see the article EPiServer Forms: Adding custom client side validation to form field (Luhn algorithm). …

EPiServer Forms: Forcing a field block to use a certain validator

There may arise situations where your custom EPiServer Forms field blocks make no sense without your custom validation code being applied as the website visitor submits the form. In these cases it may be useful to help the web editor by preventing the need to tick the correct validation checkbox in the form element block. Creds to my collegue Christer Bermar for his work on …

EPiServer Forms: Moving your EPiSever Forms views to another location

By default, EPiServer Form views goes in the directory /Views/Shared/ElementBlocks/, however if you’d like them placed elsewhere, this is easily done by adding a simple service configuration and extending EPiServer’s CustomViewLocationBase making an addition to it’s Paths array; see below. MyCustomViewLocationBase.cs Above code will allow you to keep views in a Forms directory in the Views/Shared folder.

NullReferenceException in EPiServer EPiResourcesController causing edit mode load to fail

In one of my current projects EPiServer‘s edit mode suddenly stopped working. Only the top bar loaded, while the rest failed due to a JavaScript error (see image below). NetworkError: 500 Internal Server Error caused by GetResourcesDictionary throwing NullReferenceException To investigate, we tried surfing to the failing JavaScript resource (http://{host}/EPiServer/Shell/10.7.1.0/ClientResources/EPi/shell/ui/nls/en-us/contenttypes.js) only to discover that the 500 Internal Server Error was caused by a NullReferenceException. Stack …

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 …

Sitemap.xml links show up in Google Search result using EPiServer sitemap.xml generator

For my current client’s site we realized that our sitemap.xml was indexed by Google, making it appear in our search result. While we want search engines to crawl the sitemap, we do not want it indexed. We are currently using a version of the EPiServer sitemap.xml generator described in the article Sitemap.xml generator engine for Multi language EPiServer 7.5 websites as well as Updated sitemap.xml …

EPiServer Content Folders ‘For All Sites’, ‘For This Site’, ‘For this Page’ not showing up in edit mode

I was investigating a failing Selenium test the other day and ran into a bit of trouble. It occured as the EPiServer content database template had been restored and EPiServer was loading the site for the first time after an application pool recycle (For more information on the template database testing environment, please see this article: Keeping reliable test data in EPiServer content database for …

EPiServer edit mode dojo not working after switching to Visual Studio 2015

I recently got myself a brand new computer at work running the latest Visual Studio – Visual Studio 2015. After setting up a client’s EPiServer 10 environment I found everything working as expected; until I tried editing pages through EPiServer’s edit mode. In FireFox (version 50.1.0) I got a top menu, the site preview as well as the left and right content panels; however, I …

Foreign key constraint violation for tblPropertyDefintion causing SqlException while automatically restoring EPiServer database for UI tests

Previously I wrote an article about Keeping reliable test data in EPiServer content database for automated UI tests, but recently ran into some issues in regards to new EPiServer properties. A call to the IContentRepository method Save as below. Causes the following error. Cause of SqlException foreign key constraint tblWorkContentProperty tblPropertyDefinition in EPiServer database After adding new EPiServer properties to a page type class, the …

Keeping reliable test data in EPiServer content database for automated UI tests

In my current client’s EPiServer 9 website project we are using Selenium to run automated UI tests on our code. For this we keep an EPiServer content database backup which we restore before each execution of the test suite. This ensures that any alterations to the content made by the tests are reset before each run. In previous projects we’ve kept a somewhat fresh dump …

EPiServer 9.5 PageTree disappears on upgrade: Pages, Sites, Tasks moved to Blocks, Media area

We recently upgraded a client’s EPiServer 8.5 public multilanguage website to EPiServer 9.5 in production. Everything had worked just fine when going through both system testing as well as acceptance testing environments, but for this final step we hit a small snag. It seemed as if a few of our webeditor and webadministrator SQL user accounts had a problem introduced into their edit mode interfaces. …

Manage EPiServer global settings in multilanguage multisite environment

Previously I wrote an article about an Easy way to manage global settings in multilanguage EPiServer website, but have since then had the need to expand this functionality a little (If you feel this article lacks code, check the old one to get it). Together with my collegue Thomas Durrani from Atiendo Consulting I refactored the existing code to also work in a multisite EPiServer …

Problems with ImageVault’s Shadow Copy Cache after upgrade to ImageVault 4.8

We started to experience a problem with a clients ImageVault installation after doing an upgrade to version 4.8.219.113 of the product. Large images being stored on a network share started to cause the MediaStreamService to throw Internal Server Errors while being fetched by the website. The ImageVault Core itself is not load balanced, but the EPiServer installation is however distributed over a couple of front …

ImageVault Core service not working due to mismatch with database schema and code versions

Just as a note to self. We recently did a POC on upgrading to the latest EPiServer (8.5 to 9.5) and ImageVault (4.X to 4.8) versions for my current client’s website. Everything went as expected, there were a few things that wouldn’t build in Visual Studio which were easily fixed. After switching back to do work in another Git branch I returned to the POC …

Possible causes of 401 Unauthorized ImageVaultException: Unable to request access token @ https://localhost:9901/oauth/token

The last couple of weeks I’ve been fiddling alot with various ImageVault instances and certificates in different environments and found that a common source of annoyance is the ImageVaultException stating that it’s Unable to request access token @ https://localhost:9901/oauth/token. It’s not always straight forward what might be causing this problem. I’ve summarized a couple of possible culprits in this article. The ImageVault sdkIdentity secret The …

Simple functionality for hreflang metadata in EPiServer websites

The alternate hreflang tag is a way of letting search engines such as Google know about the different languages that your pages exist in. It’s a signal to the engines that they may use in order to serve more relevant content to users based on language. One place to put this information is directly in the markup as below (Other alternatives here). A translated page …

Reminders when changing user on ImageVault Core Windows Service

We needed to change the service account user running the ImageVault Core service in my current client’s production environment the other day. Here are a few reminders on what this actually means; that’ll likely also be useful setting up new environments. Changing user on ImageVault Host Service (MyInstance) ImageVault Core’s service needs access to your image files Why does half of my ImageVault images work, …