<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Frederik Vig - ASP.NET developer &#187; EPiServer</title>
	<atom:link href="http://www.frederikvig.com/category/episerver/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.frederikvig.com</link>
	<description></description>
	<lastBuildDate>Wed, 28 Dec 2011 23:33:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Geta.oEmbed version 1.2 is out</title>
		<link>http://www.frederikvig.com/2011/11/geta-oembed-version-1-2-is-out/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=geta-oembed-version-1-2-is-out</link>
		<comments>http://www.frederikvig.com/2011/11/geta-oembed-version-1-2-is-out/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 18:50:59 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[geta]]></category>
		<category><![CDATA[oembed]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1711</guid>
		<description><![CDATA[Due to a changes in the oEmbed API I&#8217;m using for this module (it got bought by Embedly), I&#8217;ve updated the code to use the new API instead. The biggest change on your part is that you need to register on Embedly to obtain a key for the API. Registration To get the key register ...]]></description>
			<content:encoded><![CDATA[<p>Due to a changes in the oEmbed API I&#8217;m using for this module (it got bought by <a href="http://embed.ly">Embedly</a>), I&#8217;ve updated the code to use the new API instead. The biggest change on your part is that you need to register on <a href="http://embed.ly">Embedly</a> to obtain a key for the API.</p>
<h3>Registration</h3>
<p>To get the key register on this page: <a href="http://embed.ly/pricing">Embedly Pricing Plan</a>, if you scroll to the bottom you&#8217;ll see the free version which should be plenty for most uses (there is among other things a restriction on the number of requests).</p>
<p>After the registration you should receive the key in your email inbox. Add this key to your sites appSettings configuration.</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;EmbedKey&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;your-key-goes-here&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
</div>
</div>
<p>The great thing about Embedly is the support for <strong>220 different providers</strong>, here&#8217;s the list: <a href="http://embed.ly/providers">Providers</a>.</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/oembed-providers.png" alt="oEmbed providers" />
</p>
<h3>Upgrade</h3>
<p>You can get the latest version (Geta.oEmbed 1.2) from <a href="http://nuget.episerver.com">nuget.episerver.com</a>, or download the source code from <a href="https://bitbucket.org/GetaAS/opensource">Geta&#8217;s Open Source repository</a>.</p>
<p> <strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2010/09/introducing-oembed-for-episerver/" rel="bookmark" title="September 25, 2010">Introducing oEmbed for EPiServer</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-1-setting-up-the-development-environment-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 4, 2009">Part 1: Setting up the development environment &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/10/creating-a-mobile-version-of-a-web-site/" rel="bookmark" title="October 4, 2009">Creating a mobile version of a web site</a></li>
<li><a href="http://www.frederikvig.com/2011/09/tags-version-0-2-released-for-episerver-cms/" rel="bookmark" title="September 5, 2011">Tags version 0.2 released for EPiServer CMS</a></li>
<li><a href="http://www.frederikvig.com/2010/11/removing-http-headers-for-asp-net-sites/" rel="bookmark" title="November 26, 2010">Removing HTTP Headers for ASP.NET sites</a></li>
</ul>
<p><!-- Similar Posts took 102.820 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/11/geta-oembed-version-1-2-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Faster EPiServer sites &#8211; client side performance</title>
		<link>http://www.frederikvig.com/2011/10/faster-episerver-sites-client-side-performance/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=faster-episerver-sites-client-side-performance</link>
		<comments>http://www.frederikvig.com/2011/10/faster-episerver-sites-client-side-performance/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 08:59:04 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Scaling]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1681</guid>
		<description><![CDATA[First part of a new series where I&#8217;m going to focus on performance and scaling. I&#8217;m going to go through all the best practices we as EPiServer developers should know about, not only to create EPiServer sites that are fast, but ultra-fast. I&#8217;m going to use the Overlook hotel sample site. The goal is of ...]]></description>
			<content:encoded><![CDATA[<p>First part of a new series where I&#8217;m going to focus on performance and scaling. I&#8217;m going to go through all the best practices we as EPiServer developers should know about, not only to create EPiServer sites that are fast, but ultra-fast.</p>
<p>I&#8217;m going to use the <a href="http://world.episerver.com/Download/Items/EPiServer-CMS/EPiServer-CMS-6-R2/EPiServer-Overlook-R2-Demo-Site/">Overlook hotel sample site</a>. The goal is of course to make it ultra-fast!</p>
<p>To follow along you should have the overlook site installed and setup. Let&#8217;s get started!</p>
<h2>Client side performance</h2>
<p>I&#8217;m using Firefox as my main developer browser, I&#8217;ll also be using three great addons for Firefox: <a href="http://getfirebug.com/">Firebug</a>, <a href="http://developer.yahoo.com/yslow/">YSlow</a>, and <a href="http://code.google.com/speed/page-speed/">Page Speed</a>.</p>
<p>If we run YSlow on the front page of overlook hotel we&#8217;ll get a score of 66/100 (grade D) with a few suggestions for improvements.</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/performance/yslow-before.png" alt="YSlow - EPiServer Overlook Hotel demo site before" />
</p>
<p>With Page Speed we get a score of 62/100.</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/performance/page-speed-before.png" alt="Page Speed - EPiServer Overlook Hotel demo site before" />
</p>
<p>I&#8217;m going to focus on IIS 7 and above, most of the stuff is also possible with IIS 6, but I&#8217;m not going to go through IIS 6.</p>
<h3>Compress components with gzip</h3>
<p>Read more about the benefits of gzipping your content here: <a href="http://developer.yahoo.com/performance/rules.html#gzip">Gzip Components</a>. </p>
<p>In IIS 7 this is very easy. First make sure you have both static and dynamic compression installed.</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/performance/gzip-compression-iis-features.png" alt="Install Static and Dynamic compression features in IIS 7" />
</p>
<p>Next step is enabling both static and dynamic compression in web.config. Go to the &lt;system.webServer&gt; section and add the following:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;urlCompression</span> <span style="color: #000066;">doDynamicCompression</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">doStaticCompression</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">dynamicCompressionBeforeCache</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
</div>
</div>
<p>Re-run both YSlow and Page Speed. Your score should now be 72 and 78 with an A in gzip.</p>
<p>You can find more information on <a href="http://www.iis.net/ConfigReference/system.webServer/urlCompression">urlCompression on IIS.NET</a>. By default IIS 7 will actually enable static and dynamic compression for you.</p>
<p>You might have spotted the httpCompression section under &lt;system.webServer&gt;.</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;httpCompression<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;text/*&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;message/*&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;application/javascript&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;application/x-javascript&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;*/*&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/staticTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dynamicTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;text/*&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;message/*&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;application/javascript&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;application/x-javascript&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;*/*&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dynamicTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scheme</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;gzip&quot;</span> <span style="color: #000066;">dll</span>=<span style="color: #ff0000;">&quot;%Windir%\system32\inetsrv\gzip.dll&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/httpCompression<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<p>You don&#8217;t actually need this section to enable gzip (IIS will just use it&#8217;s default settings), but it&#8217;s nice to know about it when you need to tweak your default gzip settings a bit. Basically urlCompression specifies what to compress and httpCompression specifies how. More information on httpCompression: <a href="http://www.iis.net/ConfigReference/system.webServer/httpCompression">HTTP Compression &lt;httpCompression&gt;</a>.</p>
<p>If we check the applicationHost.config file for IIS 7 you can see the default settings (location: %windir%\system32\inetsrv\config\applicationHost.config):</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;</span>httpCompression directory<span style="color: #008000;">=</span><span style="color: #666666;">&quot;%SystemDrive%<span style="color: #008080; font-weight: bold;">\i</span>netpub<span style="color: #008080; font-weight: bold;">\t</span>emp<span style="color: #008080; font-weight: bold;">\I</span>IS Temporary Compressed Files&quot;</span><span style="color: #008000;">&gt;</span>
	<span style="color: #008000;">&lt;</span>scheme name<span style="color: #008000;">=</span><span style="color: #666666;">&quot;gzip&quot;</span> dll<span style="color: #008000;">=</span><span style="color: #666666;">&quot;%Windir%<span style="color: #008080; font-weight: bold;">\s</span>ystem32<span style="color: #008080; font-weight: bold;">\i</span>netsrv<span style="color: #008080; font-weight: bold;">\g</span>zip.dll&quot;</span> <span style="color: #008000;">/&gt;</span>
	<span style="color: #008000;">&lt;</span>staticTypes<span style="color: #008000;">&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;text/*&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> <span style="color: #008000;">/&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;message/*&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> <span style="color: #008000;">/&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;application/x-javascript&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> <span style="color: #008000;">/&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;application/atom+xml&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> <span style="color: #008000;">/&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;application/xaml+xml&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> <span style="color: #008000;">/&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;*/*&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;false&quot;</span> <span style="color: #008000;">/&gt;</span>
	<span style="color: #008000;">&lt;/</span>staticTypes<span style="color: #008000;">&gt;</span>
	<span style="color: #008000;">&lt;</span>dynamicTypes<span style="color: #008000;">&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;text/*&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> <span style="color: #008000;">/&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;message/*&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> <span style="color: #008000;">/&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;application/x-javascript&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> <span style="color: #008000;">/&gt;</span>
		<span style="color: #008000;">&lt;</span>add mimeType<span style="color: #008000;">=</span><span style="color: #666666;">&quot;*/*&quot;</span> enabled<span style="color: #008000;">=</span><span style="color: #666666;">&quot;false&quot;</span> <span style="color: #008000;">/&gt;</span>
	<span style="color: #008000;">&lt;/</span>dynamicTypes<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>httpCompression<span style="color: #008000;">&gt;</span></pre>
</div>
</div>
<p>By default httpCompression is set to only gzip files over 2700 bytes, we can fix this by adding the following code:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;httpCompression</span> <span style="color: #000066;">directory</span>=<span style="color: #ff0000;">&quot;%SystemDrive%\websites\_compressed&quot;</span> <span style="color: #000066;">minFileSizeForComp</span>=<span style="color: #ff0000;">&quot;1024&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scheme</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;gzip&quot;</span> <span style="color: #000066;">dll</span>=<span style="color: #ff0000;">&quot;%Windir%\system32\inetsrv\gzip.dll&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;text/*&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;message/*&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;application/javascript&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;application/json&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">mimeType</span>=<span style="color: #ff0000;">&quot;*/*&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/staticTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/httpCompression<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<h3>Add Expires headers</h3>
<p>Adding Expires headers to static and dynamic files like CSS, JavaScript and images tells the client to cache the files locally, lessening the burden on the server (less requests). Making your sites resources/components cache-able. More information: <a href="developer.yahoo.com/performance/rules.html#expires">Add an Expires or a Cache-Control Header</a>.</p>
<p>Back in our sites web.config file under the &lt;system.webServer&gt; section, we have the &lt;staticContent&gt; section:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clientCache</span> <span style="color: #000066;">cacheControlMode</span>=<span style="color: #ff0000;">&quot;UseMaxAge&quot;</span> <span style="color: #000066;">cacheControlMaxAge</span>=<span style="color: #ff0000;">&quot;1.00:00:00&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/clientCache<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<p>The interesting part here is of course the <a href="http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache">clientCache element</a>. </p>
<p>UseMaxAge will add CacheControlMaxAge to the HTTP Headers sent to the client, we can then tell the client to cache the static files for 1 year:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clientCache</span> <span style="color: #000066;">cacheControlMode</span>=<span style="color: #ff0000;">&quot;UseMaxAge&quot;</span> <span style="color: #000066;">cacheControlMaxAge</span>=<span style="color: #ff0000;">&quot;365.00:00:00&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<p>With UseExpires you specify a date instead:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clientCache</span> <span style="color: #000066;">cacheControlMode</span>=<span style="color: #ff0000;">&quot;UseExpires&quot;</span> <span style="color: #000066;">httpExpires</span>=<span style="color: #ff0000;">&quot;Tue, 19 Jan 2038 03:14:07 GMT&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<p>You can only use one of these (if you&#8217;re not using the location element) at a time. I usually use MaxAge, it&#8217;s simpler and you don&#8217;t have to remember to update your settings when the date passes. </p>
<p>The important thing to remember is that if you make any changes to the static files you&#8217;ll need to use another name. You can add a querystring, change the name, or in some other way update the path to reflect that the file has changed.</p>
<p>Let&#8217;s update it to say that the client should cache the files for 1 year:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clientCache</span> <span style="color: #000066;">cacheControlMode</span>=<span style="color: #ff0000;">&quot;UseMaxAge&quot;</span> <span style="color: #000066;">cacheControlMaxAge</span>=<span style="color: #ff0000;">&quot;365.00:00:00&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<p>This helped bring the list of components down from 86 to 15. But we&#8217;re not quite finished yet.</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/performance/expires-headers-yslow1.png" alt="Down from 86 to 15 files in YSlow Add Expires headers" />
</p>
<p>EPiServer uses the location element to specify access rights and to use EPiServer&#8217;s StaticFileHandler for files located in Global Files, Page Files, Documents and other places that use Virtual Path Providers.</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;location</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;PageFiles&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handlers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;webresources&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;WebResource.axd&quot;</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;GET&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;System.Web.Handlers.AssemblyResourceLoader&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;wildcard&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;EPiServer.Web.StaticFileHandler, EPiServer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/handlers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticFile</span> <span style="color: #000066;">expirationTime</span>=<span style="color: #ff0000;">&quot;365.00:00:00&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/location<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;location</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;Documents&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handlers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;webresources&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;WebResource.axd&quot;</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;GET&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;System.Web.Handlers.AssemblyResourceLoader&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;wildcard&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;EPiServer.Web.StaticFileHandler, EPiServer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/handlers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticFile</span> <span style="color: #000066;">expirationTime</span>=<span style="color: #ff0000;">&quot;365.00:00:00&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/location<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;location</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;Global&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handlers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;webresources&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;WebResource.axd&quot;</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;GET&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;System.Web.Handlers.AssemblyResourceLoader&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;wildcard&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;EPiServer.Web.StaticFileHandler, EPiServer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/handlers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticFile</span> <span style="color: #000066;">expirationTime</span>=<span style="color: #ff0000;">&quot;365.00:00:00&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/location<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<p>More information in EPiServer&#8217;s SDK: <a href="http://sdk.episerver.com/library/cms6/Developers%20Guide/Advanced%20Features/Caching/StaticFileCaching.htm">Caching of static files</a>. This technique uses the Expires header instead of MaxAge, but with the same effect.</p>
<p>You might have noticed the &lt;caching&gt; section:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;caching<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">extension</span>=<span style="color: #ff0000;">&quot;.gif&quot;</span> <span style="color: #000066;">policy</span>=<span style="color: #ff0000;">&quot;DontCache&quot;</span> <span style="color: #000066;">kernelCachePolicy</span>=<span style="color: #ff0000;">&quot;CacheUntilChange&quot;</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;0.00:01:00&quot;</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;Any&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">extension</span>=<span style="color: #ff0000;">&quot;.png&quot;</span> <span style="color: #000066;">policy</span>=<span style="color: #ff0000;">&quot;DontCache&quot;</span> <span style="color: #000066;">kernelCachePolicy</span>=<span style="color: #ff0000;">&quot;CacheUntilChange&quot;</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;0.00:01:00&quot;</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;Any&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">extension</span>=<span style="color: #ff0000;">&quot;.js&quot;</span> <span style="color: #000066;">policy</span>=<span style="color: #ff0000;">&quot;DontCache&quot;</span> <span style="color: #000066;">kernelCachePolicy</span>=<span style="color: #ff0000;">&quot;CacheUntilChange&quot;</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;0.00:01:00&quot;</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;Any&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">extension</span>=<span style="color: #ff0000;">&quot;.css&quot;</span> <span style="color: #000066;">policy</span>=<span style="color: #ff0000;">&quot;DontCache&quot;</span> <span style="color: #000066;">kernelCachePolicy</span>=<span style="color: #ff0000;">&quot;CacheUntilChange&quot;</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;0.00:01:00&quot;</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;Any&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">extension</span>=<span style="color: #ff0000;">&quot;.jpg&quot;</span> <span style="color: #000066;">policy</span>=<span style="color: #ff0000;">&quot;DontCache&quot;</span> <span style="color: #000066;">kernelCachePolicy</span>=<span style="color: #ff0000;">&quot;CacheUntilChange&quot;</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;0.00:01:00&quot;</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;Any&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">extension</span>=<span style="color: #ff0000;">&quot;.jpeg&quot;</span> <span style="color: #000066;">policy</span>=<span style="color: #ff0000;">&quot;DontCache&quot;</span> <span style="color: #000066;">kernelCachePolicy</span>=<span style="color: #ff0000;">&quot;CacheUntilChange&quot;</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;0.00:01:00&quot;</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;Any&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/caching<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<p>The caching setting is used to configure output caching for IIS. You have both output caching for IIS and for ASP.NET. More information: <a href="http://www.iis.net/ConfigReference/system.webServer/caching">Caching &lt;caching&gt;</a>. By default IIS output caching is turned on. </p>
<p>What EPiServer has done is told IIS to not cache static files like images, CSS and JavaScript and let ASP.NET handle it instead. You can read more about IIS output caching here: <a href="http://learn.iis.net/page.aspx/710/configure-iis-7-output-caching/">Configure IIS 7 Output Caching</a>.</p>
<p>Let&#8217;s remove the whole &lt;caching&gt; section and use the default settings instead. </p>
<p>Now we have a score of 78 points in YSlow and 95 in Page Speed. Here you can see how much of the total size is now cached:</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/performance/yslow-cache.png" alt="YSlow showing the pages local cache" />
</p>
<p>On the left we can see the total size and number of requests the first time, on the right is the size and number of requests after that. We&#8217;re now down to 3 requests and 16KB. Quite an improvement don&#8217;t you think?</p>
<h3>Minify JavaScript and CSS</h3>
<p>When we&#8217;re developing we usually work with multiple JavaScript and CSS files to make it easier to structure and maintain them. However in production we should take care to automatically compress and bundle the files.</p>
<p>It&#8217;s important to note the difference between the rule <a href="http://developer.yahoo.com/performance/rules.html#gzip">Gzip Components</a> and <a href="http://developer.yahoo.com/performance/rules.html#minify">Minify JavaScript and CSS</a>, which will remove comments, unneeded whitespaces and replace variable/function names with shorter versions.</p>
<p>There are a few tools we can use for this:</p>
<ul>
<li><a href="http://nuget.org/List/Packages/SquishIt">SquishIt</a> &#8211; I&#8217;ve written about it before: <a href="http://www.frederikvig.com/2010/06/css-and-javascript-compression-and-bundling/">CSS and JavaScript compression and bundling</a></li>
<li><a href="http://nuget.org/List/Packages/Cassette.Web">Cassette</a></li>
<li><a href="http://nuget.org/List/Packages/Microsoft.Web.Optimization">ASP.NET 4.5 Optimization</a></li>
</ul>
<p>We&#8217;re going to use ASP.NET 4.5 Optimization preview. You can easily install it through NuGet. </p>
<p>Note: you&#8217;ll need to run .NET 4, so we&#8217;ll need to upgrade our solution to use .NET 4 instead of .NET 3.5. This is quite easy thanks to <a href="http://twitter.com/davidknipeta">David Knipe</a>. Change the projects target framework in Visual Studio and install the EPiServerCMS6ToNetFour package from <a href="http://nuget.episerver.com">nuget.episerver.com</a>.</p>
<p>After that you&#8217;ll be able to install ASP.NET 4.5 Optimization successfully. </p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/performance/nuget-asp-net-optimization.png" alt="ASP.NET 4.5 Optimization installation with NuGet in Visual Studio 2010" />
</p>
<p>To enable it we just call the EnableDefaultBundles() method inside Application_Start in Global.asax:</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Global <span style="color: #008000;">:</span> EPiServer<span style="color: #008000;">.</span><span style="color: #0000FF;">Global</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> Application_Start<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		BundleTable<span style="color: #008000;">.</span><span style="color: #0000FF;">Bundles</span><span style="color: #008000;">.</span><span style="color: #0000FF;">EnableDefaultBundles</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre>
</div>
</div>
<p>Next step is updating the way external JavaScript and CSS files are included. By default, everything you refer to in a folder gets bundled together (only for the same type, so JavaScript and CSS files don&#8217;t get bundled together even if they&#8217;re in the same folder).</p>
<div class="wp_syntax">
<div class="code">
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/Templates/DemoSite/Styles/Main/css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/Templates/DemoSite/Scripts/Main/js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre>
</div>
</div>
<p>We add the path to the folder followed by either /css or /js.</p>
<p>I had to manually update the code-behind files of site.master and the composer functions and change:</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;">Page<span style="color: #008000;">.</span><span style="color: #0000FF;">RegisterCSSFile</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ComposerFunctions.Teaser.Styles.Teaser.css&quot;</span>, UriSupport<span style="color: #008000;">.</span><span style="color: #0000FF;">ResolveUrlBySettings</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;/Templates/DemoSite/ComposerFunctions/Teaser/Styles/Teaser.css&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre>
</div>
</div>
<p>To:</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;">Page<span style="color: #008000;">.</span><span style="color: #0000FF;">RegisterCSSFile</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ComposerFunctions.Teaser.Styles.Teaser.css&quot;</span>, UriSupport<span style="color: #008000;">.</span><span style="color: #0000FF;">ResolveUrlBySettings</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;/Templates/DemoSite/ComposerFunctions/Teaser/Styles/css&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre>
</div>
</div>
<p>What I did was bundle the different JavaScript and CSS files into folders like components/modules and updated their references to use these folders instead.</p>
<p>There were a few inline scripts that I didn&#8217;t compress, but overall this helped a lot. I have now 97/100 points in Page Speed and 79/100 in YSlow.</p>
<h3>Make fewer HTTP requests</h3>
<p>Modern browsers can send up-to 6 requests at a time to the same domain. Older browsers up-to 2. Combining resource files like JavaScript, CSS and images into as few files as possible not only decreases the sites total size, but also make it load much faster for the client.</p>
<p>For JavaScript and CSS files we can use the technique we learned in the previous step (Minify JavaScript and CSS). For images we can use CSS sprites or embed the images.</p>
<p>What we&#8217;re going to do is embed the CSS background images into the stylsheets. I&#8217;ve borrowed the code from Mads Kristensen&#8217;s presentation on <a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-837T">Build &#8211; Optimize your website using ASP.NET and IIS8</a>.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.IO</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text.RegularExpressions</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web.Hosting</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Web.Optimization</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> EPiServer
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CssWithImagesMinify <span style="color: #008000;">:</span> CssMinify
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">readonly</span> Regex url <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;url\((([^\)]*)\?embed)\)&quot;</span>, RegexOptions<span style="color: #008000;">.</span><span style="color: #0000FF;">Singleline</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> format <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;url(data:image/{0};base64,{1})&quot;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> Process<span style="color: #008000;">&#40;</span>BundleResponse bundle<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Response</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cache</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SetLastModifiedFromFileDependencies</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Process</span><span style="color: #008000;">&#40;</span>bundle<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #6666cc; font-weight: bold;">string</span> reference <span style="color: #008000;">=</span> HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Path</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;/css&quot;</span>, <span style="color: #666666;">&quot;/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// When publishing the bundler can be called from &quot;/&quot; causing image reference to be invalid.</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>reference <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;/&quot;</span><span style="color: #008000;">&#41;</span>
                reference <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/Content/&quot;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Match match <span style="color: #0600FF; font-weight: bold;">in</span> url<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>bundle<span style="color: #008000;">.</span><span style="color: #0000FF;">Content</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                var file <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> FileInfo<span style="color: #008000;">&#40;</span>HostingEnvironment<span style="color: #008000;">.</span><span style="color: #0000FF;">MapPath</span><span style="color: #008000;">&#40;</span>reference <span style="color: #008000;">+</span> match<span style="color: #008000;">.</span><span style="color: #0000FF;">Groups</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>file<span style="color: #008000;">.</span><span style="color: #0000FF;">Exists</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    <span style="color: #6666cc; font-weight: bold;">string</span> dataUri <span style="color: #008000;">=</span> GetDataUri<span style="color: #008000;">&#40;</span>file<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    bundle<span style="color: #008000;">.</span><span style="color: #0000FF;">Content</span> <span style="color: #008000;">=</span> bundle<span style="color: #008000;">.</span><span style="color: #0000FF;">Content</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span>match<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span>, dataUri<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Response</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AddFileDependency</span><span style="color: #008000;">&#40;</span>file<span style="color: #008000;">.</span><span style="color: #0000FF;">FullName</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> GetDataUri<span style="color: #008000;">&#40;</span>FileInfo file<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> buffer <span style="color: #008000;">=</span> File<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadAllBytes</span><span style="color: #008000;">&#40;</span>file<span style="color: #008000;">.</span><span style="color: #0000FF;">FullName</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #6666cc; font-weight: bold;">string</span> ext <span style="color: #008000;">=</span> file<span style="color: #008000;">.</span><span style="color: #0000FF;">Extension</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span>format, ext, Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToBase64String</span><span style="color: #008000;">&#40;</span>buffer<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre>
</div>
</div>
<p>For all the images we want to embed we just add ?embed behind their name:</p>
<div class="wp_syntax">
<div class="code">
<pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'../Images/abuse.png?embed'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #993333;">scroll</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">transparent</span><span style="color: #00AA00;">;</span></pre>
</div>
</div>
<p>We also need to update Global.asax and tell BundleTable to use our CSS Minifier instead.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> Application_Start<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	var css <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DynamicFolderBundle<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;css&quot;</span>, <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>CssWithImagesMinify<span style="color: #008000;">&#41;</span>, <span style="color: #666666;">&quot;*.css&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	var js <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DynamicFolderBundle<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;js&quot;</span>, <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>JsMinify<span style="color: #008000;">&#41;</span>, <span style="color: #666666;">&quot;*.js&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
	BundleTable<span style="color: #008000;">.</span><span style="color: #0000FF;">Bundles</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>css<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	BundleTable<span style="color: #008000;">.</span><span style="color: #0000FF;">Bundles</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>js<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre>
</div>
</div>
<p>The CSS files now have their background images embedded automatically!</p>
<div class="wp_syntax">
<div class="code">
<pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA5IAAAAFCAYAAAA3+tN0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGFJREFUeNrs1zEKg1AQRdE/VgYN4uZcZDYXxEDSfd8W0gmeA5fpp3vVWpvSmB5pTs+0pLX3/moAAADcTlVtOe+0pyN90jf9Bu8BAADgH4YkAAAAhiQAAACGJAAAABdxCjAAa0EKFYXT/VsAAAAASUVORK5CYII=&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-y</span> <span style="color: #993333;">scroll</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">transparent</span><span style="color: #00AA00;">;</span></pre>
</div>
</div>
<p>There&#8217;s also a nice extension for Visual Studio that let&#8217;s right-click a folder inside Visual Studio and optimize all the images inside that folder: <a href="http://visualstudiogallery.msdn.microsoft.com/a56eddd3-d79b-48ac-8c8f-2db06ade77c3">Image Optimizer</a>.</p>
<p>I now have 99/100 in Page Speed and 95/100 in YSlow.</p>
<h3>Further improvements</h3>
<ul>
<li>Use a CDN &#8211; See <a href="http://developer.yahoo.com/performance/rules.html#cdn">Use a Content Delivery Network</a> and <a href="http://world.episerver.com/Blogs/Andre-Brynildsen/Dates/2011/9/Virtual-Path-Provider-for-Amazon-S3/">Virtual Path Provider for Amazon S3</a></li>
<li>Remove whitespaces and comments from HTML markup</li>
<li>Optimize CSS selectors and placement of stylesheets</li>
<li>Optimize JavaScript code, especially jQuery, remove inline code and update the placement of the JavaScript code</li>
<li><a href="http://developer.yahoo.com/performance/rules.html#dns_lookups">Reduce DNS Lookups</a> and consider using a service like <a href="http://aws.amazon.com/route53/">Amazon&#8217;s Route 53</a> for faster DNS lookups</li>
</ul>
<h3>Resources</h3>
<ul>
<li><a href="http://developer.yahoo.com/performance/rules.html">Best Practices for Speeding Up Your Web Site</a></li>
<li><a href="http://jsperf.com/">jsPerf — JavaScript performance playground</a></li>
<li><a href="http://www.webpagetest.org/">WebPageTest &#8211; Test a website&#8217;s performance</a></li>
<li><a href="http://yostudios.github.com/Spritemapper/">Spritemapper &#8211; CSS Spritemap Generator</a></li>
<li><a href="http://pagespeed.googlelabs.com/pagespeed/">Page Speed Online</a></li>
<li><a href="http://nuget.org/List/Packages/AspNetSprites-Core">ASP.NET CSS Sprites</a></li>
</ul>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2010/06/css-and-javascript-compression-and-bundling/" rel="bookmark" title="June 20, 2010">CSS and JavaScript compression and bundling</a></li>
<li><a href="http://www.frederikvig.com/2009/08/adding-css-and-javascript-files-dynamically-to-your-asp-net-page/" rel="bookmark" title="August 15, 2009">Adding CSS and JavaScript files dynamically to your ASP.NET page</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 24, 2009">Part 8: Preparing for launch – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/05/transparent-pngs/" rel="bookmark" title="May 5, 2009">Transparent PNGs</a></li>
<li><a href="http://www.frederikvig.com/2011/10/installing-episerver-live-monitor-on-iis-7-running-net-4/" rel="bookmark" title="October 7, 2011">Installing EPiServer Live Monitor on IIS 7 running .NET 4</a></li>
</ul>
<p><!-- Similar Posts took 51.423 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/10/faster-episerver-sites-client-side-performance/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Installing EPiServer Live Monitor on IIS 7 running .NET 4</title>
		<link>http://www.frederikvig.com/2011/10/installing-episerver-live-monitor-on-iis-7-running-net-4/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=installing-episerver-live-monitor-on-iis-7-running-net-4</link>
		<comments>http://www.frederikvig.com/2011/10/installing-episerver-live-monitor-on-iis-7-running-net-4/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 14:08:12 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1673</guid>
		<description><![CDATA[A client asked me to install Live Monitor for EPiServer CMS on their site today. Simple enough task, I started by reading the tech-note for the installation: Installation Instructions &#8211; Live Monitor. First problem Where is the installation file!? After a little digging around I found out that it was in the zip file for ...]]></description>
			<content:encoded><![CDATA[<p>A client asked me to install Live Monitor for EPiServer CMS on their site today. Simple enough task, I started by reading the tech-note for the installation: <a href="http://world.episerver.com/Documentation/Items/Installation-Instructions/EPiServer-CMS/Version-6/EPiServer-CMS-6-R2/Installation-Instructions---Live-Monitor/">Installation Instructions &#8211; Live Monitor</a>. </p>
<h3>First problem</h3>
<p>Where is the installation file!? After a little digging around I found out that it was in the <a href="http://world.episerver.com/Download/Items/EPiServer-CMS/EPiServer-CMS-6-R2/">zip file for EPiServer CMS</a> (Live Monitor.msi). After the installation Live Monitor was now available under the Modules node in EPiServer Deployment Center.</p>
<h3>Second problem</h3>
<p>Since we&#8217;re using Web.config transformation for updating our configurations files (web.config, episerver.config etc) when we deploy to different environments (test, staging, production), we&#8217;ve removed the namespace for episerver.config (xmlns=&#8221;http://EPiServer.Configuration.EPiServerSection&#8221;). If you try to run the installation without this namespace, you&#8217;ll get the following error:</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/live-monitor/second-problem.png" alt="EPiServer Live Monitor - Error - Cannot validate argument on parameter 'SqlServerName'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again." />
</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;episerver</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://EPiServer.Configuration.EPiServerSection&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre>
</div>
</div>
<p>Adding the namespace and rerunning the installation made the error disappear.</p>
<h3>Third problem</h3>
<p>Everything seemed to be running smoothly until I logged in and visited the Live Monitor overview. I get an error message:</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/live-monitor/third-problem.png" alt="EPiServer Live Monitor Failed to load root node!" />
</p>
<p>I suspected something was wrong with my web.config file after the installation. Since the site is running .NET 4, everytime I update or install EPiServer products/modules I need to update the new stuff that gets added. I&#8217;m using a source control system (of course you&#8217;re too), so it was quite easy for me to spot the new stuff that the Live Monitor installation added.</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;svc-Integrated&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;*.svc&quot;</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span> <span style="color: #000066;">resourceType</span>=<span style="color: #ff0000;">&quot;Unspecified&quot;</span> <span style="color: #000066;">preCondition</span>=<span style="color: #ff0000;">&quot;integratedMode&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
</div>
</div>
<p>Should be:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;svc-Integrated&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;*.svc&quot;</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;</span> <span style="color: #000066;">resourceType</span>=<span style="color: #ff0000;">&quot;Unspecified&quot;</span> <span style="color: #000066;">preCondition</span>=<span style="color: #ff0000;">&quot;integratedMode&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
</div>
</div>
<p>Cool, now I get a nice overview over the site. But there are no visitors!</p>
<h3>Fourth and last problem</h3>
<p>First I suspected that <a href="http://world.episerver.com/Documentation/Items/Installation-Instructions/EPiServer-CMS/Version-6/EPiServer-CMS-6-R2/Installation-Instructions---Live-Monitor/#usage3">the tracking code wasn&#8217;t added</a>, but a quick view source showed that everything was fine there. I then opened up Firebug and saw that I got a 404 error for TrackerHandler.ashx. Having a peek at web.config again I spotted that TrackerHandler.ascx was registered in the handlers section followed by &lt;clear /&gt;.</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handlers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;EPiTraceTracker&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;TrackerHandler.ashx&quot;</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;EPiServer.Trace.CMS.Handlers.TrackerHandler&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clear</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
</div>
</div>
<p>Moving TrackerHandler.ashx after the &lt;clear /&gt; removed the 404 error and we have visitors showing up on Live Monitors overview!</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/live-monitor/fourth-problem.png" alt="EPiServer Live Monitor is running and tracking users" />
</p>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 24, 2009">Part 8: Preparing for launch – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2010/01/episerver-code-walkthrough-1-404-handler/" rel="bookmark" title="January 29, 2010">EPiServer code walkthrough #1 &#8211; 404 handler</a></li>
<li><a href="http://www.frederikvig.com/2011/06/episerver-mail-5-r2-installation-problem/" rel="bookmark" title="June 2, 2011">EPiServer Mail 5 R2 Installation problem</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-1-setting-up-the-development-environment-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 4, 2009">Part 1: Setting up the development environment &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2010/05/episerver-developer-resources/" rel="bookmark" title="May 27, 2010">EPiServer Developer Resources</a></li>
</ul>
<p><!-- Similar Posts took 51.147 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/10/installing-episerver-live-monitor-on-iis-7-running-net-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tags version 0.2 released for EPiServer CMS</title>
		<link>http://www.frederikvig.com/2011/09/tags-version-0-2-released-for-episerver-cms/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tags-version-0-2-released-for-episerver-cms</link>
		<comments>http://www.frederikvig.com/2011/09/tags-version-0-2-released-for-episerver-cms/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 18:04:56 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Geta.Tags]]></category>
		<category><![CDATA[Tags]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1643</guid>
		<description><![CDATA[I&#8217;ve done a few updates to the Tags module for EPiServer CMS. The major change is that it&#8217;s now using the page&#8217;s PageGuid instead of PageLink (PageReference). This guaranties that the reference to the page will be correct, even when used with mirroring. The other updates I&#8217;ve done is added a scheduled job that cleans ...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve done a few updates to the <a href="http://www.frederikvig.com/2011/07/tags-for-episerver-cms/">Tags module for EPiServer CMS</a>. The major change is that it&#8217;s now using the page&#8217;s PageGuid instead of PageLink (PageReference). This guaranties that the reference to the page will be correct, even when used with mirroring. </p>
<p>The other updates I&#8217;ve done is added a scheduled job that cleans up and check&#8217;s that the tagged pages still exist and that they still have their tag. You&#8217;ll need to manually set this up in admin mode. Depending on the size of the site I&#8217;ll usually set this to 30 minutes. The job goes through all pages that have a tag and validates them.</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/tags-scheduled-job.png" alt="Tags maintenance job in EPiServer admin mode" />
</p>
<p>I&#8217;ve also implemented the TagEngine. This is a very first version so expect a few updates here soon. Here&#8217;s ITagEngine.cs</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">EPiServer.Core</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Geta.Tags.Models</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> Geta<span style="color: #008000;">.</span><span style="color: #0000FF;">Tags</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Interfaces</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> ITagEngine
    <span style="color: #008000;">&#123;</span>
        PageDataCollection GetPagesByTag<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tagName<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        PageDataCollection GetPagesByTag<span style="color: #008000;">&#40;</span>Tag tag<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        PageDataCollection GetPagesByTag<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tagName, PageReference rootPageReference<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        PageDataCollection GetPagesByTag<span style="color: #008000;">&#40;</span>Tag tag, PageReference rootPageReference<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        IEnumerable<span style="color: #008000;">&lt;</span>PageReference<span style="color: #008000;">&gt;</span> GetPageReferencesByTags<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tagNames<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        IEnumerable<span style="color: #008000;">&lt;</span>PageReference<span style="color: #008000;">&gt;</span> GetPageReferencesByTags<span style="color: #008000;">&#40;</span>IEnumerable<span style="color: #008000;">&lt;</span>Tag<span style="color: #008000;">&gt;</span> tags<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        IEnumerable<span style="color: #008000;">&lt;</span>PageReference<span style="color: #008000;">&gt;</span> GetPageReferencesByTags<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tagNames, PageReference rootPageReference<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        IEnumerable<span style="color: #008000;">&lt;</span>PageReference<span style="color: #008000;">&gt;</span> GetPageReferencesByTags<span style="color: #008000;">&#40;</span>IEnumerable<span style="color: #008000;">&lt;</span>Tag<span style="color: #008000;">&gt;</span> tags, PageReference rootPageReference<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre>
</div>
</div>
<p>You&#8217;ll of course find Tags for EPiServer CMS on <a href="http://nuget.episerver.com/">nuget.episerver.com</a>. Go and give it a try &#8211; please let me know how things go and if you have any feedback, leave a comment, <a href="http://twitter.com/frederikvig">tweet me</a> or send me an <a href="mailto:frederikvig@hotmail.com">email</a>.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2011/07/tags-for-episerver-cms/" rel="bookmark" title="July 21, 2011">Tags for EPiServer CMS</a></li>
<li><a href="http://www.frederikvig.com/2009/11/removing-duplicates-from-a-pagedatacollection/" rel="bookmark" title="November 27, 2009">Removing duplicates from a PageDataCollection</a></li>
<li><a href="http://www.frederikvig.com/2011/01/creating-custom-templates-in-visual-studio/" rel="bookmark" title="January 30, 2011">Creating custom templates in Visual Studio</a></li>
<li><a href="http://www.frederikvig.com/2010/09/guide-to-epicode-extensions/" rel="bookmark" title="September 30, 2010">Guide to EPiCode Extensions</a></li>
<li><a href="http://www.frederikvig.com/2009/06/episerver-extension-methods-part-2/" rel="bookmark" title="June 16, 2009">EPiServer Extension Methods part 2</a></li>
</ul>
<p><!-- Similar Posts took 118.170 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/09/tags-version-0-2-released-for-episerver-cms/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Easily add comment functionality to EPiServer CMS with DISQUS</title>
		<link>http://www.frederikvig.com/2011/08/easily-add-comment-functionality-to-episerver-cms-with-disqus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=easily-add-comment-functionality-to-episerver-cms-with-disqus</link>
		<comments>http://www.frederikvig.com/2011/08/easily-add-comment-functionality-to-episerver-cms-with-disqus/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 10:41:20 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Disqus]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1618</guid>
		<description><![CDATA[DISQUS is a very popular hosted comment system that makes it very easy to add comment functionality to new or existing sites. It takes care of spam, security (blacklists, whitelists), moderation, mobile and social media support and more. To get started we need to sign up at disqus.com. The next step is adding the necessary ...]]></description>
			<content:encoded><![CDATA[<p>DISQUS is a very popular hosted comment system that makes it very easy to add comment functionality to new or existing sites. It takes care of spam, security (blacklists, whitelists), moderation, mobile and social media support and more. </p>
<p>To get started we need to sign up at <a href="http://disqus.com/admin/register/">disqus.com</a>. The next step is adding the necessary JavaScript code to our site template &#8211; I created a new user control that I then can add to the templates that should have comment functionality enabled.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Control Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> AutoEventWireup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;false&quot;</span> EnableViewState<span style="color: #008000;">=</span><span style="color: #666666;">&quot;false&quot;</span> CodeBehind<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Disqus.ascx.cs&quot;</span> Inherits<span style="color: #008000;">=</span><span style="color: #666666;">&quot;EPiServer.Templates.Units.Disqus&quot;</span> <span style="color: #008000;">%&gt;</span>
&nbsp;
<span style="color: #008000;">&lt;</span>div id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;disqus_thread&quot;</span><span style="color: #008000;">&gt;&lt;/</span>div<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;</span>script type<span style="color: #008000;">=</span><span style="color: #666666;">&quot;text/javascript&quot;</span><span style="color: #008000;">&gt;</span>
    <span style="color: #008080; font-style: italic;">/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */</span>
    var disqus_shortname <span style="color: #008000;">=</span> <span style="color: #666666;">'example'</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// required: replace example with your forum shortname</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">// The following are highly recommended additional parameters. Remove the slashes in front to use.</span>
    var disqus_identifier <span style="color: #008000;">=</span> <span style="color: #666666;">'&lt;%= CurrentPage.PageGuid %&gt;'</span><span style="color: #008000;">;</span>
    var disqus_url <span style="color: #008000;">=</span> <span style="color: #666666;">'&lt;%= CurrentPage.GetExternalUrl() %&gt;'</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/* * * DON'T EDIT BELOW THIS LINE * * */</span>
    <span style="color: #008000;">&#40;</span>function <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        var dsq <span style="color: #008000;">=</span> document<span style="color: #008000;">.</span><span style="color: #0000FF;">createElement</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">'script'</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> dsq<span style="color: #008000;">.</span><span style="color: #0000FF;">type</span> <span style="color: #008000;">=</span> <span style="color: #666666;">'text/javascript'</span><span style="color: #008000;">;</span> dsq<span style="color: #008000;">.</span><span style="color: #0000FF;">async</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        dsq<span style="color: #008000;">.</span><span style="color: #0000FF;">src</span> <span style="color: #008000;">=</span> <span style="color: #666666;">'http://'</span> <span style="color: #008000;">+</span> disqus_shortname <span style="color: #008000;">+</span> <span style="color: #666666;">'.disqus.com/embed.js'</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#40;</span>document<span style="color: #008000;">.</span><span style="color: #0000FF;">getElementsByTagName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">'head'</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">||</span> document<span style="color: #008000;">.</span><span style="color: #0000FF;">getElementsByTagName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">'body'</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">appendChild</span><span style="color: #008000;">&#40;</span>dsq<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&lt;/</span>script<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;</span>noscript<span style="color: #008000;">&gt;</span>Please enable JavaScript to view the <span style="color: #008000;">&lt;</span>a href<span style="color: #008000;">=</span><span style="color: #666666;">&quot;http://disqus.com/?ref_noscript&quot;</span><span style="color: #008000;">&gt;</span>comments powered by Disqus<span style="color: #008000;">.&lt;/</span>a<span style="color: #008000;">&gt;&lt;/</span>noscript<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;</span>a href<span style="color: #008000;">=</span><span style="color: #666666;">&quot;http://disqus.com&quot;</span> <span style="color: #6666cc; font-weight: bold;">class</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;dsq-brlink&quot;</span><span style="color: #008000;">&gt;</span>blog comments powered by <span style="color: #008000;">&lt;</span>span <span style="color: #6666cc; font-weight: bold;">class</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;logo-disqus&quot;</span><span style="color: #008000;">&gt;</span>Disqus<span style="color: #008000;">&lt;/</span>span<span style="color: #008000;">&gt;&lt;/</span>a<span style="color: #008000;">&gt;</span></pre>
</div>
</div>
<p>The disqus_shortname is the shortname you used when you signed up. disqus_identifier is a unique identifier for that page (I used the CurrentPage&#8217;s PageGuid property), and disqus_url is the permalink for the page, I just used the GetExternalUrl() method of the <a href="https://www.coderesort.com/p/epicode/wiki/Extensions">Extensions library for EPiServer CMS</a> for this. That&#8217;s it, now you only need to include the user control in the templates where you want to allow comments.</p>
<p><img src="http://frederikvig.com/wp-content/uploads/disqus.png" alt="" /></p>
<p>Since I tested this locally (not on a public domain) I had to add the following variable to get it to work: var disqus_developer = 1; &#8211; which turns on developer mode for DISQUS.</p>
<h3>Comment count in lists</h3>
<p>If you have a list of pages that have comments you might want to display the number of comments that they have. DISQUS provides us with additional code we can use for just this purpose.</p>
<div class="wp_syntax">
<div class="code">
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'example'; // required: replace example with your forum shortname
&nbsp;
    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function () {
        var s = document.createElement('script'); s.async = true;
        s.type = 'text/javascript';
        s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
    }());
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre>
</div>
</div>
<p>We can add this code to the bottom of our templates (right before the closing body tag). I then created an extension method for building the link to the comments.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span> GetDisqusCommentLink<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> PageData page<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	var link <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TagBuilder<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;a&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #6666cc; font-weight: bold;">string</span> url <span style="color: #008000;">=</span> page<span style="color: #008000;">.</span><span style="color: #0000FF;">LinkURL</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;#disqus_thread&quot;</span><span style="color: #008000;">;</span>
&nbsp;
	link<span style="color: #008000;">.</span><span style="color: #0000FF;">MergeAttribute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;href&quot;</span>, url<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	link<span style="color: #008000;">.</span><span style="color: #0000FF;">MergeAttribute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;data-disqus-identifier&quot;</span>, page<span style="color: #008000;">.</span><span style="color: #0000FF;">PageGuid</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #0600FF; font-weight: bold;">return</span> link<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span>TagRenderMode<span style="color: #008000;">.</span><span style="color: #0000FF;">Normal</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre>
</div>
</div>
<p>To use the TagBuilder class you&#8217;ll need to add a reference to System.Web.Mvc.dll (version 2 ships with EPiServer CMS 6 R2).</p>
<p><img src="http://frederikvig.com/wp-content/uploads/comment-count.png" alt="" /></p>
<p>There&#8217;s a lot more you can do with DISQUS, I encourage you to take a look at their <a href="http://docs.disqus.com/developers/">developer docs</a> and to try it out.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/08/adding-css-and-javascript-files-dynamically-to-your-asp-net-page/" rel="bookmark" title="August 15, 2009">Adding CSS and JavaScript files dynamically to your ASP.NET page</a></li>
<li><a href="http://www.frederikvig.com/2010/10/avoiding-conflicts-when-using-jquery-and-episerver-composer/" rel="bookmark" title="October 25, 2010">Avoiding conflicts when using jQuery and EPiServer Composer</a></li>
<li><a href="http://www.frederikvig.com/2010/05/creating-a-contact-form-with-asp-net-mvc/" rel="bookmark" title="May 13, 2010">Creating a contact form with ASP.NET MVC</a></li>
<li><a href="http://www.frederikvig.com/2009/10/font-resizing-and-printing-with-jquery/" rel="bookmark" title="October 27, 2009">Font resizing and printing with jQuery</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-4-creating-the-standard-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 13, 2009">Part 4: Creating the standard page – Create an EPiServer site from scratch</a></li>
</ul>
<p><!-- Similar Posts took 140.235 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/08/easily-add-comment-functionality-to-episerver-cms-with-disqus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tags for EPiServer CMS</title>
		<link>http://www.frederikvig.com/2011/07/tags-for-episerver-cms/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tags-for-episerver-cms</link>
		<comments>http://www.frederikvig.com/2011/07/tags-for-episerver-cms/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 10:32:24 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Geta.Tags]]></category>
		<category><![CDATA[Tags]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1608</guid>
		<description><![CDATA[I&#8217;ve started working on a new module for EPiServer CMS that adds tagging functionality to EPiServer Pages. This is something I&#8217;ve seen the need for in a lot of my projects lately. In the past I&#8217;ve used everything from the built in categories to custom solutions. The concept is quite simple, editors want a way ...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started working on a new module for EPiServer CMS that adds tagging functionality to EPiServer Pages. This is something I&#8217;ve seen the need for in a lot of my projects lately. In the past I&#8217;ve used everything from the built in categories to custom solutions. The concept is quite simple, editors want a way to add more meta data to their pages, which then can be used for finding relevant pages, creating lists, facades navigation in search pages etc.</p>
<p>The module consists of two parts at the moment:</p>
<ul>
<li>Custom property for adding tags to a page</li>
<li>TagEngine for finding pages with tags</li>
</ul>
<h3>Tags property</h3>
<p>When adding Geta.Tags to your project a new custom property (Tags) will get added:</p>
<p>
<img src="/wp-content/uploads/geta.tags/custom-property-tags.png" alt="New custom property Tags" />
</p>
<p>
<img src="/wp-content/uploads/geta.tags/add-property-tags.png" alt="Add property Tags" />
</p>
<p>In edit mode this looks something like this:</p>
<p>
<img src="/wp-content/uploads/geta.tags/new-page.png" alt="New page" />
</p>
<p>
<img src="/wp-content/uploads/geta.tags/tags-with-content.png" alt="Tags for EPiServer with content" />
</p>
<p>
<img src="/wp-content/uploads/geta.tags/tags-autocomplete.png" alt="Tags for EPiServer with auto complete functionality" />
</p>
<p>Notice in the last screenshot that you get autocomplete for existing tags. You can add as many pages to a tag as you like, but each tag is unique, so you can only have one &#8216;uk&#8217; tag, &#8216;europe&#8217; tag etc. </p>
<h3>TagEngine</h3>
<p>TagEngine is used for finding pages based on one or more tags. You can specify a starting point (root PageReference), otherwise you&#8217;ll get back all pages tagged with that tag.</p>
<p>TagEngine looks like this at the moment:</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> ITagEngine
<span style="color: #008000;">&#123;</span>
    PageDataCollection GetPagesByTag<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tagName<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    PageDataCollection GetPagesByTag<span style="color: #008000;">&#40;</span>Tag tag<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    PageDataCollection GetPagesByTag<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tagName, PageReference rootPageReference<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    PageDataCollection GetPagesByTag<span style="color: #008000;">&#40;</span>Tag tag, PageReference rootPageReference<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    PageReferenceCollection GetPageReferencesByTags<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tagNames<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    PageReferenceCollection GetPageReferencesByTags<span style="color: #008000;">&#40;</span>IEnumerable<span style="color: #008000;">&lt;</span>Tag<span style="color: #008000;">&gt;</span> tags<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    PageReferenceCollection GetPageReferencesByTags<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tagNames, PageReference rootPageReference<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    PageReferenceCollection GetPageReferencesByTags<span style="color: #008000;">&#40;</span>IEnumerable<span style="color: #008000;">&lt;</span>Tag<span style="color: #008000;">&gt;</span> tags, PageReference rootPageReference<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre>
</div>
</div>
<p>I can&#8217;t promise that this is how the finale version is going to look. I&#8217;m also considering a more fluent approach.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;">tagEngine<span style="color: #008000;">.</span><span style="color: #0000FF;">Tag</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;customer&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetPages</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
tagEngine<span style="color: #008000;">.</span><span style="color: #0000FF;">Tag</span><span style="color: #008000;">&#40;</span>tag<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetPages</span><span style="color: #008000;">&#40;</span>rootPageReference<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
tagEngine<span style="color: #008000;">.</span><span style="color: #0000FF;">Tags</span><span style="color: #008000;">&#40;</span>tagCollection<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetPageReferences</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre>
</div>
</div>
<p>I&#8217;m open to suggestions/ideas <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h3>Behind the scenes</h3>
<p>All of Tags data is saved in Dynamic Data Store. When a page is saved that has a Tags property I check if it&#8217;s a new or existing tag, I then add the PageReference of the page (only PageId not WorkId) to a PageReferences collection.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>EPiServerDataStore<span style="color: #008000;">&#40;</span>AutomaticallyCreateStore <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span>, AutomaticallyRemapStore <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Tag
<span style="color: #008000;">&#123;</span>
	<span style="color: #0600FF; font-weight: bold;">public</span> Identity Id <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Name <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
	<span style="color: #008080; font-style: italic;">/// Lowercase, words combined by - between them</span>
	<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
	<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Slug <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Description <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #008080; font-style: italic;">// number of objects, pages that use this term</span>
	<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Count <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF; font-weight: bold;">public</span> PageReferenceCollection PageReferences <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre>
</div>
</div>
<p>There are a couple of problems with this approach:</p>
<ul>
<li>Mirroring &#8211; not guaranteed to get the same PageId</li>
<li>Globalization &#8211; same tags get added to all versions</li>
</ul>
<p>I then have a scheduled job that basically cleans everything up, makes sure there are no PageReferences to pages that no longer exist or have removed their tag. This job is not implemented yet.</p>
<h3>Coming soon</h3>
<ul>
<li>A more stable version for <a href="http://nuget.episerver.com">nuget.episerver.com</a></li>
<li>Implementation of TagEngine and TagsScheduledJob</li>
<li>Settings class for the Tags property</li>
</ul>
<h3>Project homepage</h3>
<p>You can find the <a href="https://www.coderesort.com/p/epicode/wiki/Tags">project homepage</a> on <a href="https://www.coderesort.com/p/epicode/wiki/WikiStart">EPiCode</a> and the <a href="https://www.coderesort.com/p/epicode/browser/Geta.Tags">source code here</a>.</p>
<p>I&#8217;m very open to suggestions and ideas. Do you think this will be useful?<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2011/09/tags-version-0-2-released-for-episerver-cms/" rel="bookmark" title="September 5, 2011">Tags version 0.2 released for EPiServer CMS</a></li>
<li><a href="http://www.frederikvig.com/2009/11/removing-duplicates-from-a-pagedatacollection/" rel="bookmark" title="November 27, 2009">Removing duplicates from a PageDataCollection</a></li>
<li><a href="http://www.frederikvig.com/2009/06/episerver-filter-part-2/" rel="bookmark" title="June 28, 2009">EPiServer filter – part 2: create your own filter</a></li>
<li><a href="http://www.frederikvig.com/2009/05/episerver-filter-part-1/" rel="bookmark" title="May 28, 2009">EPiServer filter &#8211; part 1</a></li>
<li><a href="http://www.frederikvig.com/2009/06/episerver-extension-methods-part-2/" rel="bookmark" title="June 16, 2009">EPiServer Extension Methods part 2</a></li>
</ul>
<p><!-- Similar Posts took 15.358 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/07/tags-for-episerver-cms/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>EPiServer Mail 5 R2: The stored procedure &#8216;spEPiServerMailSampleRecipientSourceGetMailingLists&#8217; doesn&#8217;t exist</title>
		<link>http://www.frederikvig.com/2011/06/episerver-mail-5-r2-the-stored-procedure-spepiservermailsamplerecipientsourcegetmailinglists-doesnt-exist/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=episerver-mail-5-r2-the-stored-procedure-spepiservermailsamplerecipientsourcegetmailinglists-doesnt-exist</link>
		<comments>http://www.frederikvig.com/2011/06/episerver-mail-5-r2-the-stored-procedure-spepiservermailsamplerecipientsourcegetmailinglists-doesnt-exist/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 18:18:50 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[EPiServer Mail]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1596</guid>
		<description><![CDATA[After completing the installation of EPiServer Mail 5 R2 (see my previous post: EPiServer Mail 5 R2 Installation problem). Everything seemed to be going fine, except for in edit mode. After the installation, when I tried editing a page, I got the following error message in edit mode (standard EPiServer CMS 6 R2 with EPiServer ...]]></description>
			<content:encoded><![CDATA[<p>After completing the installation of EPiServer Mail 5 R2 (see my previous post: <a href="http://www.frederikvig.com/2011/06/episerver-mail-5-r2-installation-problem/">EPiServer Mail 5 R2 Installation problem</a>). Everything seemed to be going fine, except for in edit mode. After the installation, when I tried editing a page, I got the following error message in edit mode (standard EPiServer CMS 6 R2 with EPiServer Mail 5 R2):</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>InvalidOperationException<span style="color: #008000;">:</span> The stored procedure <span style="color: #666666;">'spEPiServerMailSampleRecipientSourceGetMailingLists'</span> doesn<span style="color: #666666;">'t exist.]
   System.Data.SqlClient.SqlCommand.DeriveParameters() +2840515
   System.Data.SqlClient.SqlCommandBuilder.DeriveParameters(SqlCommand command) +241
   Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase.DeriveParameters(DbCommand discoveryCommand) +72
   Microsoft.Practices.EnterpriseLibrary.Data.Database.DiscoverParameters(DbCommand command) +194
   Microsoft.Practices.EnterpriseLibrary.Data.ParameterCache.SetParameters(DbCommand command, Database database) +132
   Microsoft.Practices.EnterpriseLibrary.Data.Database.GetStoredProcCommand(String storedProcedureName, Object[] parameterValues) +135
   EPiServer.Common.Data.DatabaseHandler.GetCommand(Boolean inTransaction, String sp, CommandType commandType, Object[] args) +208
   EPiServer.Common.Data.DatabaseHandler.GetReader(Boolean inTransaction, String sp, CommandType commandType, Object[] args) +32
   EPiServer.Common.Data.DatabaseHandler.GetReader(Boolean inTransaction, String sp, Object[] args) +26
   EPiServer.Mail.Sources.SampleSource.SampleSource.GetRecipientContainers(ISite site, Int32 page, Int32 pageSize, Int32&amp; totalItems, RecipientContainerSortOrder[] order) +302
   EPiServer.Mail.Core.EP.Web.ComposeNewMailControl.BindRecipientContainers() +480
   EPiServer.Mail.Core.EP.Web.ComposeNewMailControl.InitializeRecipientsSection() +789
   EPiServer.Mail.Core.EP.Web.ComposeNewMailControl.Page_Init(Object sender, EventArgs e) +72
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.UI.Control.InitRecursive(Control namingContainer) +133
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1954</span></pre>
</div>
</div>
<p>After looking a little at the stack trace and at the download section of EPiServer World I noticed the <a href="http://world.episerver.com/Download/Items/EPiServer-Mail/EPiServer-Mail-5-R2/EPiServer-Mail-50-Code-Sample/">code sample for EPiServer Mail</a>. After downloading the files I found two sql-scripts (EPiServerMailSampleRecipientSource_stored_procedures.sql and EPiServerMailSampleRecipientSource_tables.sql) that add a couple of tables and stored procedures that you apparently need. After executing both sql-scripts in my EPiServer Mail database everything worked fine again, and I was able to access edit mode.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2011/06/episerver-mail-5-r2-installation-problem/" rel="bookmark" title="June 2, 2011">EPiServer Mail 5 R2 Installation problem</a></li>
<li><a href="http://www.frederikvig.com/2010/03/starting-out-with-xslt-in-umbraco/" rel="bookmark" title="March 20, 2010">Starting out with XSLT in Umbraco</a></li>
<li><a href="http://www.frederikvig.com/2009/10/creating-an-episerver-plugin/" rel="bookmark" title="October 8, 2009">Creating an EPiServer Plugin</a></li>
<li><a href="http://www.frederikvig.com/2009/10/sending-confirmation-email-to-the-user-when-using-episerver-xforms/" rel="bookmark" title="October 17, 2009">Sending confirmation email to the user when using EPiServer XForms</a></li>
<li><a href="http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/" rel="bookmark" title="February 28, 2010">Adding different CSS classes when using the EPiServer PageTree control</a></li>
</ul>
<p><!-- Similar Posts took 34.054 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/06/episerver-mail-5-r2-the-stored-procedure-spepiservermailsamplerecipientsourcegetmailinglists-doesnt-exist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EPiServer Mail 5 R2 Installation problem</title>
		<link>http://www.frederikvig.com/2011/06/episerver-mail-5-r2-installation-problem/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=episerver-mail-5-r2-installation-problem</link>
		<comments>http://www.frederikvig.com/2011/06/episerver-mail-5-r2-installation-problem/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 16:00:47 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[EPiServer Mail]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1591</guid>
		<description><![CDATA[When trying to install EPiServer Mail 5 R2 on an existing site I came across this bug: #65398. At C:\Program Files &#40;x86&#41;\EPiServer\Mail\5.1.343.270\Install\System Scripts\Install Site &#40;No Database&#41;.ps1:297 char:20 + Update-EPiXmlFile &#60;&#60;&#60;&#60; -TargetFilePath $webConfigFilePath -ModificationFilePath &#40;Join-Path $appWebConfigSourcePath 'web.config.modification.clearhandlers.xml'&#41; System.IO.FileNotFoundException: Could not find file 'C:\Program Files (x86)\EPiServer\Mail\5.1.343.270\Install\Configuration\web.config.modification.clearhandlers.xml'. File name: 'C:\Program Files (x86)\EPiServer\Mail\5.1.343.270\Install\Configuration\web.config.modification.clearhandlers.xml' at System.IO.__Error.WinIOError&#40;Int32 errorCode, String maybeFullPath&#41; at ...]]></description>
			<content:encoded><![CDATA[<p>When trying to install EPiServer Mail 5 R2 on an existing site I came across this bug: <a href="http://world.episerver.com/bugs#bug,EPiServer%20Mail,65398,Smxc%2b97BIueSjmQuGC6LhgDtqbw%3d">#65398</a>.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;">At C<span style="color: #008000;">:</span>\Program Files <span style="color: #008000;">&#40;</span>x86<span style="color: #008000;">&#41;</span>\EPiServer\Mail\5<span style="color: #008000;">.</span>1<span style="color: #008000;">.</span>343<span style="color: #008000;">.</span>270\Install\<span style="color: #000000;">System</span> Scripts\Install Site <span style="color: #008000;">&#40;</span>No Database<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ps1</span><span style="color: #008000;">:</span><span style="color: #FF0000;">297</span> <span style="color: #6666cc; font-weight: bold;">char</span><span style="color: #008000;">:</span><span style="color: #FF0000;">20</span>
<span style="color: #008000;">+</span>         Update<span style="color: #008000;">-</span>EPiXmlFile <span style="color: #008000;">&lt;&lt;&lt;&lt;</span>  <span style="color: #008000;">-</span>TargetFilePath $webConfigFilePath <span style="color: #008000;">-</span>ModificationFilePath <span style="color: #008000;">&#40;</span>Join<span style="color: #008000;">-</span>Path $appWebConfigSourcePath <span style="color: #666666;">'web.config.modification.clearhandlers.xml'</span><span style="color: #008000;">&#41;</span>
<span style="color: #000000;">System.<span style="color: #0000FF;">IO</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">FileNotFoundException</span><span style="color: #008000;">:</span> Could not find file <span style="color: #666666;">'C:<span style="color: #008080; font-weight: bold;">\P</span>rogram Files (x86)<span style="color: #008080; font-weight: bold;">\E</span>PiServer<span style="color: #008080; font-weight: bold;">\M</span>ail<span style="color: #008080; font-weight: bold;">\5</span>.1.343.270<span style="color: #008080; font-weight: bold;">\I</span>nstall<span style="color: #008080; font-weight: bold;">\C</span>onfiguration<span style="color: #008080; font-weight: bold;">\w</span>eb.config.modification.clearhandlers.xml'</span><span style="color: #008000;">.</span>
<span style="color: #0000FF;">File</span> name<span style="color: #008000;">:</span> <span style="color: #666666;">'C:<span style="color: #008080; font-weight: bold;">\P</span>rogram Files (x86)<span style="color: #008080; font-weight: bold;">\E</span>PiServer<span style="color: #008080; font-weight: bold;">\M</span>ail<span style="color: #008080; font-weight: bold;">\5</span>.1.343.270<span style="color: #008080; font-weight: bold;">\I</span>nstall<span style="color: #008080; font-weight: bold;">\C</span>onfiguration<span style="color: #008080; font-weight: bold;">\w</span>eb.config.modification.clearhandlers.xml'</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">IO</span></span><span style="color: #008000;">.</span>__Error<span style="color: #008000;">.</span><span style="color: #0000FF;">WinIOError</span><span style="color: #008000;">&#40;</span>Int32 errorCode, <span style="color: #6666cc; font-weight: bold;">String</span> maybeFullPath<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">IO</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">FileStream</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Init</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span> path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, <span style="color: #6666cc; font-weight: bold;">String</span> msgPath, Boolean bFromProxy<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">IO</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">FileStream</span><span style="color: #008000;">..</span><span style="color: #0000FF;">ctor</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span> path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlDownloadManager</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetStream</span><span style="color: #008000;">&#40;</span>Uri uri, ICredentials credentials<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlUrlResolver</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetEntity</span><span style="color: #008000;">&#40;</span>Uri absoluteUri, <span style="color: #6666cc; font-weight: bold;">String</span> role, Type ofObjectToReturn<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlTextReaderImpl</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OpenUrlDelegate</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">Object</span> xmlResolver<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Threading</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">CompressedStack</span><span style="color: #008000;">.</span><span style="color: #0000FF;">runTryCode</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">Object</span> userData<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Runtime</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CompilerServices</span><span style="color: #008000;">.</span><span style="color: #0000FF;">RuntimeHelpers</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ExecuteCodeWithGuaranteedCleanup</span><span style="color: #008000;">&#40;</span>TryCode code, CleanupCode backoutCode, <span style="color: #6666cc; font-weight: bold;">Object</span> userData<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Threading</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">CompressedStack</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Run</span><span style="color: #008000;">&#40;</span>CompressedStack compressedStack, ContextCallback callback, <span style="color: #6666cc; font-weight: bold;">Object</span> state<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlTextReaderImpl</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OpenUrl</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlTextReaderImpl</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Read</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlLoader</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span>XmlDocument doc, XmlReader reader, Boolean preserveWhitespace<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlDocument</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span>XmlReader reader<span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlDocument</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span> filename<span style="color: #008000;">&#41;</span>
   at EPiServer<span style="color: #008000;">.</span><span style="color: #0000FF;">Install</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Xml</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Installers</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UpdateXmlInstaller</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SetUpSubInstallers</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
   at EPiServer<span style="color: #008000;">.</span><span style="color: #0000FF;">Install</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Xml</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Installers</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UpdateXmlInstaller</span><span style="color: #008000;">..</span><span style="color: #0000FF;">ctor</span><span style="color: #008000;">&#40;</span>InstallationManager installationManager, <span style="color: #6666cc; font-weight: bold;">String</span> targetFilePath, <span style="color: #6666cc; font-weight: bold;">String</span> modificationsFilePath, Dictionary`<span style="color: #FF0000;">2</span> namespaces, Dictionary`<span style="color: #FF0000;">2</span> replaces, Boolean autoAddNamespaces<span style="color: #008000;">&#41;</span>
   at EPiServer<span style="color: #008000;">.</span><span style="color: #0000FF;">Install</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Xml</span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlInstallationManager</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UpdateXml</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span> targetFilePath, <span style="color: #6666cc; font-weight: bold;">String</span> modificationFilePath, Dictionary`<span style="color: #FF0000;">2</span> namespaces, Dictionary`<span style="color: #FF0000;">2</span> replaces, Boolean autoAddNamespaces<span style="color: #008000;">&#41;</span>
   at EPiServer<span style="color: #008000;">.</span><span style="color: #0000FF;">Install</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Xml</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cmdlets</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UpdateConfigCmdlet</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ProcessRecord</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Management</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Automation</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cmdlet</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DoProcessRecord</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
   at <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Management</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Automation</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CommandProcessor</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ProcessRecord</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span></pre>
</div>
</div>
<p>The fix turned out to be quite simple. Comment out the &lt;clear /&gt; element under the &lt;handlers&gt; section of the sites web.config before the installation (uncomment after). This solved it for me and the installation completed without any troubles.</p>
<p>Big thanks to EPiServer Support for helping me with this problem.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2011/06/episerver-mail-5-r2-the-stored-procedure-spepiservermailsamplerecipientsourcegetmailinglists-doesnt-exist/" rel="bookmark" title="June 2, 2011">EPiServer Mail 5 R2: The stored procedure &#8216;spEPiServerMailSampleRecipientSourceGetMailingLists&#8217; doesn&#8217;t exist</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-1-setting-up-the-development-environment-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 4, 2009">Part 1: Setting up the development environment &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 24, 2009">Part 8: Preparing for launch – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2011/10/installing-episerver-live-monitor-on-iis-7-running-net-4/" rel="bookmark" title="October 7, 2011">Installing EPiServer Live Monitor on IIS 7 running .NET 4</a></li>
<li><a href="http://www.frederikvig.com/2009/08/adding-css-and-javascript-files-dynamically-to-your-asp-net-page/" rel="bookmark" title="August 15, 2009">Adding CSS and JavaScript files dynamically to your ASP.NET page</a></li>
</ul>
<p><!-- Similar Posts took 65.665 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/06/episerver-mail-5-r2-installation-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Part 1: Injection &#8211; OWASP Top 10 for EPiServer Developers</title>
		<link>http://www.frederikvig.com/2011/05/part-1-injection-owasp-top-10-for-episerver-developers-3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=part-1-injection-owasp-top-10-for-episerver-developers-3</link>
		<comments>http://www.frederikvig.com/2011/05/part-1-injection-owasp-top-10-for-episerver-developers-3/#comments</comments>
		<pubDate>Sun, 22 May 2011 13:04:02 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[OWASP]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1577</guid>
		<description><![CDATA[Injection flaws have always been one of the biggest security wholes in web applications. The good news is that it is very easy to protect against them, ones you know how. So what is injection? Injection flaws, such as SQL, OS, and LDAP injection, occur when untrusteddata is sent to an interpreter as part of ...]]></description>
			<content:encoded><![CDATA[<p>Injection flaws have always been one of the biggest security wholes in web applications. The good news is that it is very easy to protect against them, ones you know how.</p>
<p>So what is injection?</p>
<blockquote>
<p>
Injection flaws, such as SQL, OS, and LDAP injection, occur when untrusteddata is sent to an interpreter as part of a command or query. The attacker’s hostile data can trick the interpreter into executing unintended commands or accessing unauthorized data.
</p>
</blockquote>
<p>What this means is that evil input data (from querystrings, form data, HTTP Headers etc) cause your applications queries or commands to change (in a way not designed by you as the developer of the application).</p>
<p>The most common form is SQL injection. Eg:</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">string</span> query <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;SELECT * FROM customers WHERE ID='&quot;</span> <span style="color: #008000;">+</span> Request<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;id&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span></pre>
</div>
</div>
<p>The attacker can then simple modify either the querystring, form data or the HTTP header collection. </p>
<p>http://example.com/customers?id=&#8217; or &#8217;1&#8242;=&#8217;1</p>
<p>This allows the attacker to view the customer information they like, or even go as far as deleting the table (if they run in a user context that has enough database rights).</p>
<p>One way to fix this is to either use parameters or stored procedures:</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">string</span> query <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;SELECT * FROM customers WHERE ID=@id&quot;</span><span style="color: #008000;">;</span>
SqlCommand command <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SqlCommand<span style="color: #008000;">&#40;</span>query, connection<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
SqlParameter idParameter <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SqlParameter<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@id&quot;</span>, SqlDbType<span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">Int</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> Value <span style="color: #008000;">=</span> Request<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;id&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
command<span style="color: #008000;">.</span><span style="color: #0000FF;">Parameters</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>idParameter<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre>
</div>
</div>
<p>This is better, now when someones tries to run http://example.com/app/accountView?id=&#8217; or &#8217;1&#8242;=&#8217;1 they&#8217;ll get an error (since we&#8217;ve defined that id is an integer, ADO.NET takes care of sanitizing the input).</p>
<h3>Validate all input</h3>
<p>First rule is to always code defensively. An attacker can easily modify everything sent to you, without needing a HTML form. HTTP proxies like <a href="http://www.fiddler2.com/fiddler2/">Fiddler</a> make this easy. It is much safer for us to whitelist input (specify what we consider valid input), than to blacklist input (specify what is not allowed). The reason for this is simple, you know what is accepted and valid and can make sure that the input matches that pattern. With blacklisting there is a infinitive number of different patterns we&#8217;d need to validate against.</p>
<p>In the case above where we accept an ID, which in our case only consists of integers. We can use the int.TryParse() method to validate the input:</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TryParse</span><span style="color: #008000;">&#40;</span>Request<span style="color: #008000;">.</span><span style="color: #0000FF;">QueryString</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;id&quot;</span><span style="color: #008000;">&#93;</span>, <span style="color: #0600FF; font-weight: bold;">out</span> id<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  lblMessage<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Invalid customer id.&quot;</span><span style="color: #008000;">;</span>
  <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// valid integer number</span></pre>
</div>
</div>
<p>Notice that we now only check the querystring (I&#8217;m not using Request["id"] anymore), We also validate and make sure that this is a number. Taking this a step further we could make sure that the number follows a pattern that we&#8217;ve defined for customer IDs (at least 4 digits, only positive numbers etc), by using a regular expression.</p>
<h3>Dynamic Data Store</h3>
<p>With EPiServer CMS 6 came the Dynamic Data Store, (more information on <a href="http://world.episerver.com/Documentation/Items/Tech-Notes/EPiServer-CMS-6/EPiServer-CMS-6-R2/Dynamic-Data-Store/">Dynamic Data Store</a>). EPiServer has a factory class for accessing the dynamic data store: DynamicDataStoreFactory. We then use LINQ and Lambda to query the data. If you&#8217;ve used ORM tools like NHibernate, LINQ to SQL, Entity Framework etc before this should be familiar. The LINQ and Lambda code then gets translated to SQL code by both using parameters and stored procedures (which protect us against SQL-injections). If you&#8217;re curious how this code looks, take a look at the <a href="http://sdk.episerver.com/episerverframework/6.2/html/AllMembers_T_EPiServer_Data_Dynamic_Providers_SqlServerDataStoreProvider.htm">SqlServerDataStoreProvider class</a> in EPiServer.Data.dll.</p>
<p>Always, always use EPiServer&#8217;s API when accessing EPiServer data. Not only does it protect against security vulnerbilities like SQL-injection, it also adds smart caching, event notifications and other goodies.<br />
<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/09/extending-search-field-with-suggestion-box/" rel="bookmark" title="September 17, 2009">Extending search field with suggestion box</a></li>
<li><a href="http://www.frederikvig.com/2009/06/using-multiple-forms-on-an-asp-net-web-forms-page/" rel="bookmark" title="June 21, 2009">Using multiple forms on an ASP.NET web forms page</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-5-creating-the-search-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 16, 2009">Part 5: Creating the search page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2010/10/how-to-add-support-for-iframes-and-other-elements-to-tinymce-in-episerver-cms/" rel="bookmark" title="October 18, 2010">How to add support for iframes (and other elements) to TinyMCE in EPiServer CMS</a></li>
<li><a href="http://www.frederikvig.com/2010/04/detecting-ajax-requests-on-the-server/" rel="bookmark" title="April 6, 2010">Detecting Ajax requests on the server</a></li>
</ul>
<p><!-- Similar Posts took 23.572 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/05/part-1-injection-owasp-top-10-for-episerver-developers-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS3 buttons and EPiServer editor stylesheet</title>
		<link>http://www.frederikvig.com/2011/05/css3-buttons-and-episerver-editor-stylesheet/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css3-buttons-and-episerver-editor-stylesheet</link>
		<comments>http://www.frederikvig.com/2011/05/css3-buttons-and-episerver-editor-stylesheet/#comments</comments>
		<pubDate>Sun, 08 May 2011 11:21:43 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1552</guid>
		<description><![CDATA[You&#8217;ve probably seen them around, the cool new CSS3 styled buttons. Before you had to use images and image replacement to achieve a similar effect. Now you can do this without images and by only using CSS. The cool thing about this is that it makes it so much easier to use on our sites. ...]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve probably seen them around, the cool new CSS3 styled buttons. Before you had to use images and image replacement to achieve a similar effect. Now you can do this without images and by only using CSS. The cool thing about this is that it makes it so much easier to use on our sites. We can easily add these buttons to the editor stylesheet and let our editors choose from the different action buttons that they are allowed to use. </p>
<p>Here is a button that we can use in three different colors. As you can see the only change needed is the additional HTML class.</p>
<div class="wp_syntax">
<div class="code">
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;action-button blue&quot;</span>&gt;</span>Blue button<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;action-button green&quot;</span>&gt;</span>Green button<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;action-button orange&quot;</span>&gt;</span>Orange button<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></pre>
</div>
</div>
<p>The CSS code looks like this:</p>
<div class="wp_syntax">
<div class="code">
<pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.action-button</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.action-button</span><span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">3px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">3px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-1px</span> <span style="color: #933;">1px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.25</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.action-button</span>.<span style="color: #993333;">green</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.action-button</span>.<span style="color: #993333;">green</span><span style="color: #3333ff;">:visited		</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#99c70a</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.action-button</span>.<span style="color: #993333;">green</span><span style="color: #3333ff;">:hover						</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#6f9302</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.action-button</span>.<span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.action-button</span>.<span style="color: #000000; font-weight: bold;">blue</span><span style="color: #3333ff;">:visited		</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#22adbf</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.action-button</span>.<span style="color: #000000; font-weight: bold;">blue</span><span style="color: #3333ff;">:hover							</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#017691</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.action-button</span><span style="color: #6666ff;">.orange</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.action-button</span><span style="color: #6666ff;">.orange</span><span style="color: #3333ff;">:visited		</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ff5c00</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.action-button</span><span style="color: #6666ff;">.orange</span><span style="color: #3333ff;">:hover							</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#d45500</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre>
</div>
</div>
<p>To make it work in Internet Explorer as well we can use <a href="http://css3pie.com/">CSS3 PIE</a>.</p>
<p>We can easily add these three buttons to the editor stylesheet so that our editors can pick them from the styles drop down list in TinyMCE.</p>
<div class="wp_syntax">
<div class="code">
<pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.action-button</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.action-button</span><span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">3px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">3px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-1px</span> <span style="color: #933;">1px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.25</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.action-button</span>.<span style="color: #993333;">green</span>
<span style="color: #00AA00;">&#123;</span>
    EditMenuTitle<span style="color: #00AA00;">:</span> Buttons<span style="color: #00AA00;">;</span>
	EditMenuName<span style="color: #00AA00;">:</span> Green<span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#99c70a</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.action-button</span>.<span style="color: #000000; font-weight: bold;">blue</span> <span style="color: #00AA00;">&#123;</span>
	EditMenuName<span style="color: #00AA00;">:</span> Blue<span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#22adbf</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.action-button</span><span style="color: #6666ff;">.orange</span> <span style="color: #00AA00;">&#123;</span>
	EditMenuName<span style="color: #00AA00;">:</span> Orange<span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ff5c00</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre>
</div>
</div>
<p>You can set the path to your editor stylesheet in episerver.config, under site settings and uiEditorCssPaths or by adding a dynamic property with the name UIEditorCssPaths.</p>
<p>This will add the options green, blue and orange to the style drop down list, grouped under the Buttons title:</p>
<p>
<img src="http://frederikvig.com/wp-content/uploads/tinymce/tinyemce.png" alt="" />
</p>
<p>We can now select any link and apply the button look to it. The result:</p>
<p>
<img src="http://frederikvig.com/wp-content/uploads/tinymce/result.png" alt="" />
</p>
<p>Pretty cool huh?<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2010/04/episerver-file-manager-and-file-summary/" rel="bookmark" title="April 2, 2010">EPiServer File Manager and File Summary</a></li>
<li><a href="http://www.frederikvig.com/2009/05/css-tricks-part-1/" rel="bookmark" title="May 31, 2009">CSS tricks &#8211; part 1</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-5-creating-the-search-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 16, 2009">Part 5: Creating the search page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/11/better-breadcrumb-trail/" rel="bookmark" title="November 14, 2009">Better breadcrumb trail</a></li>
<li><a href="http://www.frederikvig.com/2009/09/creating-a-custom-episerver-paging-control/" rel="bookmark" title="September 20, 2009">Creating a Custom EPiServer Paging Control</a></li>
</ul>
<p><!-- Similar Posts took 32.876 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/05/css3-buttons-and-episerver-editor-stylesheet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
