C# Archive

Custom property Checkbox wrapper as Dynamic Property in EPiServer 7.5

We needed to add a checkbox as a dynamic property in my current client’s EPiServer 7.5 site last week. It’s not as straight forward as one might think due to the way that dynamic properties are handled. If you add a dynamic checkbox property through admin mode, together with a property decorated with the attribute in your code, everything will work fine up until …

Rewrite URL before ValidateInputIfRequiredByConfig throws ‘A potentially dangerous Request.Path value was detected from the client (&).’ exception

A client are on their way to migrate a large website from an old platform to a brand new EPiServer 7.5 site running on an IIS webserver. We created a small redirection engine to handle all incoming legacy URLs redirecting them to the proper pages on the new website, so as not to lose search engine ranking, visitor bookmarks and so on. However, the legacy …

Adding items to EPiServer’s global menu in edit/admin mode

We needed to create a custom toolbox in EPiServer‘s edit mode as a central place of keeping additional functionality for a client’s 7.5 website. The global menu seemed like an excellent place to do this. For a brief description on how to get EPiServer’s global menu on your own pages see this previous article. Here is a short note on how it can be done; …

ContentLink ArgumentNullException while saving AccessControlList on EPiServer page created programmatically

I received a disturbing ArgumentNullException today while removing read access for the Everyone role on new pages created in codebehind. Not really difficult once you figure it out, but I thought I’d provide an example to show how it may be done. EPiServer ContentLink value cannot be null calling ACL.Save method At first glance it may seem as it is a good idea to take …

Notes about default property values in EPiServer 7.5

I needed to set default values for a couple of my EPiServer 7.5 block and page properties today, and found Per Mange Skuseth‘s article on Attribute-based default values. I really like Per’s way of dealing with them, as you get to have each default value in connection with the property that it will affect, rather than stoving them away in some obscure method override chunk …

EPiServer 7.5 throwing System.Data.SqlClient.SqlException (0x80131904): editSaveContentVersionData: The WorkContentId dosen´t exist (WorkContentID=0)

A short note on another EPiServer exception that I encountered today while trying to save a newly created EPiServer page programmatically from codebehind. The reason for it is rather self explaining looking back at it. It’s not possible to force the current version as it does not exist yet, Doh.. So just finding myself content with only doing what is neccessary fixed the problem right …

An alternate way of managing your tabs in EPiServer 7.5; adding and changing

I needed to add a few extra tabs to our EPiServer 7.5 installation last week, and found Per Magne Skuseth‘s comment on Tabs and sort index to be really useful. Of course I managed to alter the piece of code beyond recognition while integrating it into my current project’s architecture. Here is a StructureMap twist on adding and changing tabs. Easy way of adding and …

Using NLog with EPiServer and log4net

In my current EPiServer project we decided to use NLog for our logging needs rather than going with log4net. Since EPiServer has a dependency on the latter we wanted a way of bridging EPiServer’s log messages to our own NLog setup. This was accomplished by creating a new appender for log4net, redirecting all relevant log messages to it and converting them into something that NLog …

Security fix for the Language File Editor tool in EPiServer 7.5

I applied the security fix that I made for the EPiServer CMS 6 R2 version of the Language File Editor tool to the EPiServer 7 version that Hannu Hartikainen made earlier. Also did some code refactoring and removed the possibility for web administrators to create their own language files, as well as deleting existing ones; these were a source for potential headache. Code available at …

Security fix for the Language File Editor tool in EPiServer CMS 6 R2

In 2011 I wrote a tool allowing web administrators to edit EPiServer’s language XML files through admin mode. As the code was constructed it assumed that the environment was properly set up (i.e. securing the plugins preventing unauthorized access), thus trusting the user. Anyhow, failing to do so opened up for unauthorized users to read/modify/delete certain files on the server/shares. Here is a summary of …

Cache manager easing cache handling for EPiServer 7.5 with ISynchronizedObjectInstanceCache

We had this splendid little cache manager in my previous project that simplified handling caching for us. It was written by a former collegue of mine, Patrik Akselsson, and last week I found a need for a similar thing at my new client’s. Looking back at what I already had, I set about making a similar CacheManager that would work with the new EPiServer 7.5 …

Resolving your own and EPiServer’s dependencies without the EPiServer ServiceLocator

I recently got my hands on a new project at work and wanted to see if I could avoid using EPiServer‘s ServiceLocator to resolve the dependencies in my code. From previous projects I was used to being able to inject whatever I needed directly through the constructor, and felt that I wanted to continue doing so. For instance, my class CanHasCookies implements the interface ICanHasCookies …

Scheduled jobs with input parameters in EPiServer 7.5

The other day I got a question from a collegue of mine whether or not the piece I wrote on supplying scheduled jobs with input parameters (EPiServer CMS6R2) would still work for version 7.5. I suspected it would, but since I wanted to make sure I set up two of EPiServer’s Alloy template sites; one using WebForms and the other with MVC. Tweaked source code …

Easier log file retrieval in EPiServer 7.5 for environments with limited access to servers

I wrote a small EPiServer admin tool the other day in order to make it easier to retrieve log files without having direct access to the webserver. It is a rather straight forward piece that lists the files of a certain directory, and writes their content to the response output stream when clicked on. Limitations include the tool not taking load balanced multi server environments …

Orphaned translation scanner for EPiServer language files

My current project has undergone some rather large changes the last couple of months; core functionality being moved out of the solution, functionality needing to be cleaned away and so forth. I suspected that we were left with a rather large number of stray translations in our EPiServer language files because of this, so I took some time and wrote a small console tool to …

New Relic’s Real User Monitoring (RUM) breaks the EPiServer’s File Manager in Edit Mode

Update: There is a hotfix available for this, see Per’s comment further down. We noticed a weird problem on one of our test servers in my current project some time ago. For some reason there was a massive output of JavaScript in the EPiServer ActionWindow, in addition to the normal functionality making it impossible to use the file manager. Us not experiencing anything like it …

EPiServer 7 Installation Error – $accountName is not a valid user or group

I ran into some problems the other day trying to install an EPiServer 7 site onto an old Windows 7 developer machine using EPiServer‘s Deployment Center. Everything seemed to be going well until I was hit with an account related error. Opening up the installation PowerShell script file in question (\EPiServer\CMS\7.0.586.1\Install\System Scripts\Install Site (No database).ps1) soon revield what was going on. Apparently the EPiServer installation …

Insert links to bookmarks in other EPiServer pages

EPiServer‘s insert link dialog has an option that allows web editors to insert links to anchor tag bookmarks contained within the page currently being edited. This option, however, is not yet available when using the Page on this website alternative as a Link target. A client requested similar functionality for their EPiServer CMS 6 R2 installation, so I and my collegue Joachim Widén spent a …