<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by Henrik Molnes</title><link href="http://world.optimizely.com" /><updated>2014-10-17T07:50:00.0000000Z</updated><id>https://world.optimizely.com/blogs/Henrik-Molnes/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>Disable rendring of a block based on it&#39;s content</title><link href="http://henrikm.com/disable-rendring-of-a-block-based-on-its-content/" /><id>&lt;p&gt;Let&#39;s say we have a block defined like below. The problem that need to be solved occurs when the property &lt;code&gt;ContentBlockLink&lt;/code&gt; is pointing to a page that the user does not have access to. Could be because of StartPublish, &lt;a href=&quot;/link/fdb75bbf65194537ab48e7f8de72a9a6.aspx&quot;&gt;role membership&lt;/a&gt; or something else. Then the whole block should not be visible for the user.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/hmol/ce538ddf85c62f6ff579.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;Instead of having the &lt;em&gt;don&#39;t-render-me&lt;/em&gt; logic in the view, factory or the controller, the best place to disable the rendering would in fact be inside the &lt;code&gt;Render()&lt;/code&gt; method of &lt;code&gt;IContentRendrer&lt;/code&gt;. This method is respoinsible for rendering all blocks. Could be done like this:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/hmol/7ef7e18ebcfca5c01fbc.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;To be able to use &lt;code&gt;CustomContentRenderer&lt;/code&gt; you need to swap it with the default &lt;code&gt;ContentRendrer&lt;/code&gt;. This is done by using dependency injection. A good example on doing it with StructureMap is seen here: &lt;br /&gt;
&lt;a href=&quot;https://github.com/kennethdevik/alloytechazure/blob/master/AlloyTechAzure/Business/Initialization/DependencyResolverInitialization.cs&quot;&gt;https://github.com/kennethdevik/alloytechazure/blob/master/AlloyTechAzure/Business/Initialization/DependencyResolverInitialization.cs&lt;/a&gt;&lt;/p&gt;</id><updated>2014-10-17T07:50:00.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Custom validation of properties in EPiServer 7</title><link href="http://henrikm.com/custom-episerver-property-validation/" /><id>&lt;p&gt;In EPiServer 7 (and newer versions) developers can easlily validate input from editors and display a message. There are 3 different severities:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ValidationErrorSeverity.Info&lt;/code&gt;&lt;img src=&quot;http://henrikm.com/content/images/2014/Sep/info.png&quot; alt=&quot;&quot; title=&quot;&quot; /&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ValidationErrorSeverity.Warning&lt;/code&gt;&lt;img src=&quot;http://henrikm.com/content/images/2014/Sep/warning.png&quot; alt=&quot;&quot; title=&quot;&quot; /&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ValidationErrorSeverity.Error&lt;/code&gt; (Page cannot be saved)&lt;img src=&quot;http://henrikm.com/content/images/2014/Sep/error.png&quot; alt=&quot;&quot; title=&quot;&quot; /&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementing custom validation of properties in code can be done in two different ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Validation of all properties that are assigned with a custom attribute. This only supports &lt;code&gt;ValidationErrorSeverity.Error&lt;/code&gt;   &lt;script src=&quot;https://gist.github.com/hmol/6c7a955df0af56e0f4bd.js&quot;&gt;&lt;/script&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Validation of properties that exists on a specific pagetype. Supports all 3 severities.   &lt;script src=&quot;https://gist.github.com/hmol/37ddf2e060e808afd88b.js&quot;&gt;&lt;/script&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;br /&gt; &lt;br /&gt;
Other relevant reading:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.david-tec.com/2012/06/EPiServer-7-Preview---Using-validation-attributes/&quot;&gt;http://www.david-tec.com/2012/06/EPiServer-7-Preview---Using-validation-attributes/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.david-tec.com/2012/06/EPiServer-7-Preview---IValidator-interface/&quot;&gt;http://www.david-tec.com/2012/06/EPiServer-7-Preview---IValidator-interface/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/link/52c750a171ee49ada7103835315dfa08.aspx&quot;&gt;http://world.episerver.com/Blogs/Alexander-Haneng/Dates/2012/7/How-to-define-properties-in-EPiServer-7---A-quick-reference/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/link/f4d86e3ecfad4be8aa4a1e55d5fae6df.aspx&quot;&gt;http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2013/12/Restriction-of-content-types-in-properties/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</id><updated>2014-10-09T16:00:00.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Using VppMigrationTool returns exception (Could not load file or assembly..)</title><link href="https://world.optimizely.com/blogs/Henrik-Molnes/Dates/2014/2/Using-VppMigrationTool-returns-exception-Could-not-load-file-or-assembly/" /><id>&lt;p&gt;&lt;font size=&quot;4&quot;&gt;This is migth be a bit too specific, but when using the VppMigrationTool to migrate files to EPiServer 7.5 I got this error when trying to connect to the site:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://henrikm.com/epiimgs/VppMigrationTool_E4A7/Capture.png&quot;&gt;&lt;img title=&quot;Capture&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;Capture&quot; src=&quot;http://henrikm.com/epiimgs/VppMigrationTool_E4A7/Capture_thumb.png&quot; width=&quot;554&quot; height=&quot;575&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p style=&quot;height: 96px; width: 100.78%&quot;&gt;&lt;font size=&quot;3&quot; face=&quot;Consolas&quot;&gt;Could not load file or assembly &#39;file:///C:\Users\pa_hemo\Downloads\EPiServer_7.5_VppMigrationTool\VppMigrationTool_20140107.1\VppMigrationTool.exe&#39; or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) &lt;font size=&quot;3&quot; face=&quot;Consolas&quot;&gt;at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&amp;amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;4&quot; face=&quot;Consolas&quot;&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;4&quot; face=&quot;Consolas&quot;&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;4&quot;&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;4&quot;&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;4&quot;&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;4&quot;&gt;At the bottom of the exception you get a little hint, but it took me&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font size=&quot;4&quot;&gt;some minutes to figure it out. The solution is to add the config settings below in to your &lt;font face=&quot;Consolas&quot;&gt;Machine.config-&lt;/font&gt;&lt;font face=&quot;Calibri&quot;&gt;file:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;pre&gt;&lt;font size=&quot;4&quot; face=&quot;Consolas&quot;&gt;&amp;lt;configuration&amp;gt;
   &amp;lt;runtime&amp;gt;
      &amp;lt;loadFromRemoteSources enabled=&amp;quot;true&amp;quot;/&amp;gt;
   &amp;lt;/runtime&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font size=&quot;4&quot;&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size=&quot;4&quot;&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size=&quot;4&quot;&gt;This did the trick for me :)&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font face=&quot;Consolas&quot;&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size=&quot;4&quot;&gt;You can also change the &lt;font face=&quot;Consolas&quot;&gt;VppMigrationTool.exe.config&lt;/font&gt;&amp;#160; to look like this:&lt;/font&gt;&lt;/p&gt;

&lt;pre style=&quot;height: 304px; width: 100%&quot;&gt;&lt;p&gt; &lt;font size=&quot;3&quot;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;/font&gt; &lt;/p&gt;&lt;p&gt; &lt;font size=&quot;3&quot;&gt;&amp;lt;configuration&amp;gt;&lt;/font&gt; &lt;/p&gt;&lt;p&gt; &lt;font size=&quot;3&quot;&gt;&amp;#160;&amp;#160; &amp;lt;startup&amp;gt; &lt;/font&gt; &lt;/p&gt;&lt;p&gt; &lt;font size=&quot;3&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;supportedRuntime version=&amp;quot;v4.0&amp;quot; sku=&amp;quot;.NETFramework,Version=v4.0&amp;quot;/&amp;gt;&lt;/font&gt; &lt;/p&gt;&lt;p&gt; &lt;font size=&quot;3&quot;&gt;&amp;#160;&amp;#160; &amp;lt;/startup&amp;gt;&lt;/font&gt; &lt;/p&gt;&lt;p&gt; &lt;font size=&quot;3&quot;&gt;&amp;#160;&amp;#160; &amp;lt;runtime&amp;gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt; &lt;/p&gt;&lt;p&gt; &lt;font size=&quot;3&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;loadFromRemoteSources enabled=&amp;quot;true&amp;quot;/&amp;gt;&lt;/font&gt; &lt;/p&gt;&lt;p&gt; &lt;font size=&quot;3&quot;&gt;&amp;#160;&amp;#160; &amp;lt;/runtime&amp;gt; &lt;/font&gt; &lt;/p&gt;&lt;p&gt; &lt;font size=&quot;3&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/font&gt; &lt;/p&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font size=&quot;4&quot;&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;
  

  

  &lt;p&gt;&lt;font size=&quot;4&quot;&gt;&lt;/font&gt;&lt;/p&gt;

  &lt;p&gt;&lt;font size=&quot;4&quot;&gt;PS: You should also be aware that VppMigrationTool removes the config-settings from web.config for the folders you choose migrate.&lt;/font&gt;&lt;/p&gt;&lt;/p&gt;</id><updated>2014-02-17T10:56:39.0000000Z</updated><summary type="html">Blog post</summary></entry></feed>