<?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>Fredrik Haglund's blog &#187; ASP.NET</title>
	<atom:link href="http://blog.fredrikhaglund.se/blog/tag/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fredrikhaglund.se</link>
	<description>Chatter about EPiServer, ASP.NET, CSS and Web Development.</description>
	<lastBuildDate>Thu, 15 Apr 2010 09:14:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>TechDays: Dino Esposito&#8217;s ASP.NET 4.0 highlights</title>
		<link>http://blog.fredrikhaglund.se/blog/2010/03/23/techdays-dino-espositos-asp-net-4-0-highlights/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2010/03/23/techdays-dino-espositos-asp-net-4-0-highlights/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 11:23:22 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET 4.0]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/blog/2010/03/23/techdays-dino-espositos-asp-net-4-0-highlights/</guid>
		<description><![CDATA[In short, ASP.NET 4.0, gives you more control.

CSS friendly HTML from Server Controls by default.
EnableViewState does not work as you expect in ASP.NET 2.0. With the new ViewStateMode property with values: Inherit, Enable and Disable you get what you expect.
ClientIDMode with value Predictable generates shorter ID attributes and possible for humans and javascript developers to [...]]]></description>
			<content:encoded><![CDATA[<p>In short, ASP.NET 4.0, gives you more control.</p>
<ul>
<li>CSS friendly HTML from Server Controls by default.</li>
<li>EnableViewState does not work as you expect in ASP.NET 2.0. With the new ViewStateMode property with values: Inherit, Enable and Disable you get what you expect.</li>
<li>ClientIDMode with value Predictable generates shorter ID attributes and possible for humans and javascript developers to handle.</li>
<li>I think Auto-Encoding is going to be valuable for EPiServer Developers. The Auto encoding blocks “&lt;%: … %&gt;” and the IHtmlString marker interface that ensures you do not encode a string twice.</li>
<li>For SEO there are properties on Page class for MetaKeywords and MetaDescription. Also support for both 301 and 302 redirects and Routing gives Friendly URL instead of path to aspx-files.</li>
</ul>
<p>And <a href="http://weblogs.asp.net/despos/" target="_blank">much more at Dinos blog</a>…</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2010/03/23/techdays-dino-espositos-asp-net-4-0-highlights/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Are you safe? Dangers of XSS&#8230;</title>
		<link>http://blog.fredrikhaglund.se/blog/2009/06/03/cross-site-scripting-xss/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2009/06/03/cross-site-scripting-xss/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 07:55:34 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=210</guid>
		<description><![CDATA[If you allow the visitors of your site to contribute, for example with a simple comment this textbox, you take the risk that a malicious user inject evil code in a comment.
This evil code is then executed in the browser by your sites&#8217; ordinary visitors. Scripts can steals passwords (maybe your own admin account), trick the user [...]]]></description>
			<content:encoded><![CDATA[<p>If you allow the visitors of your site to contribute, for example with a simple comment this textbox, you take the risk that a malicious user inject evil code in a comment.</p>
<p>This evil code is then executed in the browser by your sites&#8217; ordinary visitors. Scripts can steals passwords (maybe your own admin account), trick the user to give up other senestive data or download malvare because they trust your site.</p>
<p>This kind of security vulnerability is reffered to as <a title="Wikipedia" href="http://en.wikipedia.org/wiki/Cross-site_scripting">XSS or Cross Site Scripting</a>. </p>
<h3>Always have input validation and filter you input</h3>
<p>A common aproach is to sanitize the data with a whitelisted or blacklisted characters to eliminate dangerous characters before storing or using the data. Another, is to always html encode data when it is rendered.  But it is harder than you think to get it right!</p>
<h3>70 ways to write the same character</h3>
<p>So you think you are smart and have a string replace or regular expression that removes &#8220;&lt;&#8221; from the user&#8217;s input on your website to be safe? I guess you need to test again&#8230; I had too!</p>
<p>Did you know that there is 70 diffrent ways to write the &#8220;&lt;&#8221; character in html? <a href="http://ha.ckers.org/xss.html" target="_blank">Read Robert Hansen&#8217;s good cheat sheet that lists known XSS attacks to get scared and take the problem serionsly</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2009/06/03/cross-site-scripting-xss/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get control over your assembly dependencies</title>
		<link>http://blog.fredrikhaglund.se/blog/2008/02/23/get-control-over-your-assembly-dependencies/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2008/02/23/get-control-over-your-assembly-dependencies/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 09:54:01 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Assembly]]></category>
		<category><![CDATA[bindingRedirect]]></category>
		<category><![CDATA[FileLoadException]]></category>
		<category><![CDATA[Fusion]]></category>
		<category><![CDATA[Fuslogvw]]></category>
		<category><![CDATA[PlugInException]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/blog/2008/02/23/get-control-over-your-assembly-dependencies/</guid>
		<description><![CDATA[Suddenly everything stops working you do not have clue what’s gone wrong. You just get annoying exceptions thrown in your face explaining that it could not find a specific version of a DLL or that the located assembly’s manifest definition does not match the assembly reference.
Sometimes you can see a Yellow Screen of Death telling [...]]]></description>
			<content:encoded><![CDATA[<p>Suddenly everything stops working you do not have clue what’s gone wrong. You just get annoying exceptions thrown in your face explaining that it could not find a specific version of a DLL or that the located assembly’s manifest definition does not match the assembly reference.</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2008/02/ysod-could-not-load-file-or-assembly.png" title="YSOD-Could not load file or assembly"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2008/02/ysod-could-not-load-file-or-assembly.thumbnail.png" alt="YSOD-Could not load file or assembly" class="imageleft" /></a>Sometimes you can see a Yellow Screen of Death telling you that you application tries to use a version of an assembly that you know that you do not want to use. But why?</p>
<h3>Visual Studio add <em>&lt;assemblies&gt;</em> to web.config</h3>
<p>This can be a problem if you have several different versions of an assembly installed in the <a href="http://en.wikipedia.org/wiki/Global_Assembly_Cache">GAC</a> at the same time. Under some conditions Visual Studio thinks that you must add references to assemblies to be able to successfully compile your asp.net files. Unfortunately the added references have the opposite effect – nothing compiles!</p>
<pre><span style="color: blue"><span>    </span>&lt;</span><span style="color: #a31515">compilation</span><span style="color: blue"> </span><span style="color: red">defaultLanguage</span><span style="color: blue">=</span><span>&quot;<span style="color: blue">c#</span>&quot;<span style="color: blue"> </span><span style="color: red">debug</span><span style="color: blue">=</span>&quot;<span style="color: blue">true</span>&quot;<span style="color: blue">&gt;  </span></span>
<span style="color: blue"><span>      </span>&lt;</span><span style="color: #a31515">assemblies</span><span style="color: blue">&gt;</span><span style="color: blue">  </span>
<span style="color: blue"><span>         </span>&lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span><span>&quot;<span style="color: blue">EPiServer, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span></span><span><span style="color: blue">  </span></span>
<span style="color: blue"><span>         </span>[ . . . ]</span><span style="color: blue">  </span>
<span style="color: blue"><span>      </span></span><span style="color: blue">&lt;/</span><span style="color: #a31515">assemblies</span><span style="color: blue">&gt;</span><span style="color: blue">  </span>
<span style="color: blue"><span>    </span>&lt;/</span><span style="color: #a31515">compilation</span><span style="color: blue">&gt;</span></pre>
<p>As you know your asp.net files (global.asax, aspx-files, etc) are parsed and converted to C#-code that is then compiled with the C#-compiler when first accessed. The assemblies added in the &lt;assemblies&gt;-tag are added as references in the same way as you add references to a normal project in Visual Studio. You risk getting file not found errors or strange compilation errors. Since these references are parameters to the compiler, binding redirects in the runtime tag in web.config has no effect.</p>
<p><strong>Tip:</strong> Remove the whole <em>&lt;assemblies&gt;</em>-tag or at least all EPiServer references.</p>
<h3>Visual Studio adds <em>&lt;%@ Register %&gt;</em> to your markup</h3>
<p>Another place where you can get references to unwanted versions of assemblies added by Visual Studio is in you markup. Automatically added <em>&lt;%@ Register %&gt;</em> with strongly named references to assemblies will sooner or later cause problems for you. With strongly named I mean assembly names including version number and public key. If it is just a name it will load whatever version that is placed in your bin-folder.</p>
<p><strong>Tip:</strong> Always delete &quot;&lt;% @ Register TagPrefix =&quot;EPiServer&quot; … %&gt;&quot; from you markup.</p>
<p>The import of EPiServer controls are handled elsewhere. Take a look at the <em>&lt;pages&gt;&lt;controls&gt;</em>-tag in your <em>web.config</em> and you will understand. This also has the side effect of making most of EPiServer classes available in front-end code without adding the <em>&lt;assemblies&gt;</em>-tags.</p>
<p><strong>Tip:</strong> Consider adding you own controls to the <em>&lt;pages&gt;&lt;controls&gt;</em>-tag in your <em>web.config</em> instead of adding a <em>&lt;%@ Register %&gt;</em>-tag on every page.</p>
<p><strong>Tip:</strong> Remove the version number and public key from the assembly attribute.</p>
<h3>Use &lt;bindingRedirect&gt; in your web.config</h3>
<p>The key to be able to use a new version of an assembly without recompiling everything is the <em>&lt;bindingRedirect&gt;</em>-tag in <em>web.config</em>. EPiServer Manager updates this part of your <em>web.config</em> when you upgrade your site.</p>
<pre><span style="color: blue"><span>  </span>&lt;</span><span style="color: #a31515">runtime</span><span style="color: blue">&gt;  </span>
<span style="color: blue"><span>    </span>&lt;</span><span style="color: #a31515">assemblyBinding</span><span style="color: blue"> </span><span style="color: red">xmlns</span><span style="color: blue">=</span><span>&quot;<span style="color: blue">urn:schemas-microsoft-com:asm.v1</span>&quot;<span style="color: blue">&gt;</span></span><span>
<span style="color: blue"><span style="color: blue"><span>      </span>&lt;</span><span style="color: #a31515">dependentAssembly</span><span style="color: blue">&gt;</span></span></span>
<span style="color: blue"><span>        </span>&lt;</span><span style="color: #a31515">assemblyIdentity</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span><span>&quot;<span style="color: blue">EPiServer</span>&quot;<span style="color: blue"> </span><span style="color: red">publicKeyToken</span><span style="color: blue">=</span>&quot;<span style="color: blue">8fe83dea738b45b7</span>&quot;<span style="color: blue"> </span><span style="color: red">culture</span><span style="color: blue">=</span>&quot;<span style="color: blue">neutral</span>&quot;<span style="color: blue">/&gt;</span></span><span><span style="color: blue"><span style="color: blue">
<span>        </span>&lt;</span><span style="color: #a31515">bindingRedirect</span><span style="color: blue"> </span><span style="color: red">oldVersion</span><span style="color: blue">=</span><span>&quot;<span style="color: blue">5.0.0.0-5.65535.65535.65535</span>&quot;<span style="color: blue"> </span><span style="color: red">newVersion</span><span style="color: blue">=</span>&quot;<span style="color: blue">5.1.422.4</span>&quot;<span style="color: blue">/&gt;</span></span></span></span>
<span style="color: blue"><span>      </span>&lt;/</span><span style="color: #a31515">dependentAssembly</span><span style="color: blue">&gt;</span><span></span></pre>
<h3>FileLoadException</h3>
<p>Sometimes it is not obvious why an assembly fails to load. Turn on logging in Fusion to get more information that might help you track down the issue. (Fusion is the name of the part of the dot net framework responsible for loading assemblies)</p>
<p>There is a property on <em>System.IO.FileLoadException</em> called <em>FusionLog</em> that contains details on why an assembly failed to load. The content of this property is displayed on the Yellow Screen of Death.</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2008/02/enable-fusion-log-with-regedit.png" title="Enable Fusion Log with RegEdit"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2008/02/enable-fusion-log-with-regedit.png" alt="Enable Fusion Log with RegEdit" style="width: 100%" /></a></p>
<p><strong>Tip:</strong> Enable assembly binding logging use <strong>Fusion Log Viewer</strong> (Fuslogvw.exe) or set the registry value <em>EnableLog</em> in <em>HKLM\Software\Microsoft\Fusion</em> to 1. Note that you have to restart your application (use <em>iisreset)</em> for the changes to have any effect.</p>
<p><strong>Tip:</strong> Remember to turn off fusion logging when you are done since there is a performance penalty to have it turned on.</p>
<h3>EPiServer PlugInException</h3>
<p>Sometimes the FileLoadException is an inner exception of another exception so the Yellow Screen of Death does not show the details from the fusion log. This is a quite common scenario for EPiServer since the first thing that happens when the application start is that EPiServer loads ALL assemblies in the bin-folder and searches for PlugIn-attributes.</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2008/02/assembly-binding-log-viewer-fuslogvw.png" title="Assembly Binding Log Viewer - fuslogvw"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2008/02/assembly-binding-log-viewer-fuslogvw.png" alt="Assembly Binding Log Viewer - fuslogvw" style="width: 100%" /></a></p>
<p><strong>Tip:</strong> In these cases you can change the setting in the Assembly Binding Log Viewer to &quot;Log bind failures to disk&quot; and get all the details you need to track down the issue. I also recommend using a custom log path.</p>
<h3>Fix your references by editing your csproj-file</h3>
<p>Finally, take a look at your csproj file using notepad (or unload the project in Visual Studio to be able to open it as text). When you add references using Visual Studio you will get a assembly reference with both version number and public key and this can give you some trouble when you upgrade a vendor assembly to a newer version.</p>
<pre><span style="color: blue"><span>    </span>&lt;</span><span style="color: #a31515">Reference</span><span style="color: blue"> </span><span style="color: red">Include</span><span style="color: blue">=</span><span><span style="color: #000000">&quot;</span><span style="color: blue">StarSuite.Core</span><span style="color: #000000">&quot;</span><span style="color: blue">&gt;</span></span><span><span style="color: blue">  </span></span>
<span style="color: blue"><span>      </span>&lt;</span><span style="color: #a31515">SpecificVersion</span><span style="color: blue">&gt;</span><span><span style="color: #000000">False</span><span style="color: blue">&lt;/</span><span style="color: #a31515">SpecificVersion</span><span style="color: blue">&gt;  </span></span>
<span style="color: blue"><span>      </span>&lt;</span><span style="color: #a31515">HintPath</span><span style="color: blue">&gt;</span><span><span style="color: #000000">..\Lib\StarSuite.Core.dll</span><span style="color: blue">&lt;/</span><span style="color: #a31515">HintPath</span><span style="color: blue">&gt;</span></span><span><span style="color: blue">  </span></span>
<span><span style="color: blue"><span style="color: blue"><span>      </span></span><span style="color: blue">&lt;</span><span style="color: #a31515">Private</span><span style="color: blue">&gt;</span><span><span style="color: #000000">True</span><span style="color: blue">&lt;/</span><span style="color: #a31515">Private</span><span style="color: blue">&gt;  </span></span>
<span><span style="color: blue"><span style="color: blue"><span>    </span>&lt;/</span><span style="color: #a31515">Reference</span><span style="color: blue">&gt;</span></span></span></span></span></pre>
<p><strong>Tip</strong>: Edit your csproj-file as text and keep only the assembly name. When you have removed the version and public key.</p>
<p><strong>Tip</strong>: Create a Library-folder and store a copy of all references assemblies. It can be very nice to have if Visual Studio decides that it want to clean the bin folder and removes files that you need there.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2008/02/23/get-control-over-your-assembly-dependencies/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Web.config, version control and nice formatting</title>
		<link>http://blog.fredrikhaglund.se/blog/2008/01/12/webconfig-version-control-and-nice-formatting/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2008/01/12/webconfig-version-control-and-nice-formatting/#comments</comments>
		<pubDate>Sat, 12 Jan 2008 18:34:43 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[web.config]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=59</guid>
		<description><![CDATA[EPiServer has a site tag with a lot of attributes. When you change the web.config from EPiServer Manager or by calling Save on the Configuration class yourself all attributes will be on one looong line (this is default behaivour by the dotnet framework so its not EPiServers fault).
If you put web.config under version control and [...]]]></description>
			<content:encoded><![CDATA[<p>EPiServer has a site tag with a lot of attributes. When you change the web.config from EPiServer Manager or by calling Save on the Configuration class yourself all attributes will be on one looong line (this is default behaivour by the dotnet framework so its not EPiServers fault).</p>
<p>If you put <em>web.config</em> under version control and would prefer if changes to singe attributes are easy to detect with a diff tool, this is not the optimal.</p>
<p>It is possible to change formatting in Visual Studio to get one attribute per line and that works much better for text diff tools. (This requires that you do your changes with Notepad or Visual Studio and not use EPiServer Manager or the Admin Mode to change the settings.)</p>
<p>Go to Tools -&gt; Options -&gt; Text Editor -&gt; XML -&gt; Formatting and select &#8220;Align attributes each on a separate line&#8221;</p>
<p>Click Edit -&gt; Advanced -&gt; Format Document (or Format Selection if you only want to adjust a part of the file) before you check in your <em>web.config</em> to reformat.</p>
<p>Voilà! Your <em>web.config</em> is readable!</p>
<p>(See also <a href="http://www.episerver.com/en/EPiServer_Knowledge_Center/Developer-Forum2/EPiServer-Developer-Forums-/EPiServer-CMS-version-5/14774/">discussion in EPiServer Developer Forum</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2008/01/12/webconfig-version-control-and-nice-formatting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Protecting you e-mail address with reCaptcha</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/12/03/protecting-you-e-mail-address-with-recaptcha/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/12/03/protecting-you-e-mail-address-with-recaptcha/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 16:13:41 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Chaptcha]]></category>
		<category><![CDATA[Spam fighting]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=53</guid>
		<description><![CDATA[It is well know that once an e-mail address have been published on a home page it will not take a long time before it is flooded with spam.
The usual sollution to this is to to either use a feedback form (that do not use the mail address in clear text as a parameter) or [...]]]></description>
			<content:encoded><![CDATA[<p>It is well know that once an e-mail address have been published on a home page it will not take a long time before it is flooded with spam.</p>
<p>The usual sollution to this is to to either use a feedback form (that do not use the mail address in clear text as a parameter) or a use a Captcha to reveal it.</p>
<p>I found a new good Captcha service and API that I would like to recommend: <a href="http://mailhide.recaptcha.net/">http://mailhide.recaptcha.net/</a></p>
<p>Here is an example of how it could look like using my e-mail address:<br />
<a href="http://mailhide.recaptcha.net/d?k=01QrDPwHVJQ1jb9ev8XPXCYA==&amp;c=2K-mn1HrTXM0vdrOPL1f7IH7GrNaRujsDpneAv-XKxc=" title="Reveal this e-mail address">fred???@inexor.se</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/12/03/protecting-you-e-mail-address-with-recaptcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Profile Data in EPiServer</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/11/28/profile-data-in-episerver/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/11/28/profile-data-in-episerver/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 10:09:06 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[EPiServerProfile]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=52</guid>
		<description><![CDATA[To store settings for the current user, use the built-in Profile support in ASP.NET.
EPiServer is using this for its own need to store information on a per user basis. (The built-in values EPiServer needs are accessible through the class EPiServerProfile that is a subclass of the ASP.NET class ProfileBase).
You can get access to the current [...]]]></description>
			<content:encoded><![CDATA[<p>To store settings for the current user, use the built-in Profile support in ASP.NET.</p>
<p>EPiServer is using this for its own need to store information on a per user basis. (The built-in values EPiServer needs are accessible through the class <em>EPiServerProfile</em> that is a subclass of the ASP.NET class <em>ProfileBase</em>).</p>
<p>You can get access to the current users EPiServer&#8217;s Profile instance accessing the static property <strong>Current</strong> on the <em>EPiServerProfile</em> class. There is also a default indexer property inherited from ASP.NET&#8217;s <em>ProfileBase</em> class that you can use for you own values.</p>
<pre><code>EPiServer.Personalization.EPiServerProfile.Current["MySetting"] = "Test123";
			</code></pre>
<p>For performance reasons use only <em>string</em>, <em>int</em>, <em>DateTime</em> and avoid objects that must be serialized. There is also support for handling anonymous users (not logged in) if needed.</p>
<p>Read more: <a href="http://msdn2.microsoft.com/en-us/library/at64shx3.aspx">http://msdn2.microsoft.com/en-us/library/at64shx3.aspx</a></p>
<p><strong>Update</strong>: <a href="http://www.episerver.com/en/EPiServer_Knowledge_Center/Documentation/Release-Notes/Release-Notes---EPiServer-CMS-5-SP1/">Read more about changes to Profile information in SP1 for EPiServer CMS 5 R1</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/11/28/profile-data-in-episerver/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generation of designer file failed</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/11/27/generation-of-designer-file-failed/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/11/27/generation-of-designer-file-failed/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 00:34:59 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=49</guid>
		<description><![CDATA[The error message &#8220;Generation of designer file failed: Unknown server tag &#8216;EPiServer:Property&#8217;&#8221; in Visual Studio can really drive me mad.

Today it happened again. I noticed that I could not recompile my application because the new textbox I added to my ASPX-file did not appear as a member in the corsponding designer.cs-file.
First, I double check that [...]]]></description>
			<content:encoded><![CDATA[<p>The error message &#8220;Generation of designer file failed: Unknown server tag &#8216;EPiServer:Property&#8217;&#8221; in Visual Studio can really drive me mad.</p>
<p><img width="442" src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/11/112707-0035-generationo1.png" height="130" /></p>
<p>Today it happened again. I noticed that I could not recompile my application because the new textbox I added to my ASPX-file did not appear as a member in the corsponding designer.cs-file.</p>
<p>First, I double check that I installed SP1 for Visual Studio 2005 so I have the latest version of Web Application Projects.</p>
<h3>The Usual Trick</h3>
<p>When this happens it is in most cases an indication of a syntax error in the ASPX-file. In many cases you get so many strange errors and warnings in Visual Studio&#8217;s Error List so you do not understand what is wrong. A quick way to get a good error message and be certain that the designer.cs-file is in sync is to first delete it and then regenerating it by right-clicking the ASPX-file in the Solution Explorer and selecting &#8220;Convert to Web Application&#8221;.</p>
<p>This works in most cases. Either you will get an error you will understand how to fix or it just regenerates the designer.cs-file for you.</p>
<h3>Permanent Frustration</h3>
<p>Sometimes you will fail to generate the file and nothing you do seem to help. Everything is in order. No syntax errors in the ASPX-file. It just refuses to regenerate the designer file because it cannot find component X.</p>
<p><a href="http://forums.asp.net/search/SearchResults.aspx?q=Generation+of+designer+file+failed+Unknown+server+tag+&amp;o=Relevance">Obviously I&#8217;m not alone getting this problem</a>. I&#8217;m not sure why it stops working but I guess part of the problem is related to the ASPX-file must be parsed first and something is wrong with the environment.</p>
<p>Tim McBride on the ASP.NET team hints <a href="http://forums.asp.net/p/1003495/1524697.aspx">how to get more information by turning on debugging for Web Application Projects</a>.</p>
<pre><code>REGEDIT4
[HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio8.0WebApplicationProjectsDebug]
"LogFile"="C:logfile.txt"
"Enabled"=dword:00000001"
LogFieldGeneratorFailures"=dword:00000001
</code></pre>
<p>And with a call stack we have more information where it goes wrong:</p>
<pre><code>System.Web.HttpParseException: Unknown server tag 'EPiServer:Property'.
   at System.Web.UI.TemplateParser.ProcessError(String message)
   <strong>at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)</strong>
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
   --- End of inner exception stack trace ---
   at System.Web.UI.TemplateParser.ProcessException(Exception ex)
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
   --- End of inner exception stack trace ---
   at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ParseInternal()
   at System.Web.UI.TemplateParser.Parse()
   at System.Web.UI.DesignTimeTemplateParser.ParseTemplate(DesignTimeParseData data)
   at Microsoft.VisualStudio.Web.Application.Parser.Parse()
   at Microsoft.VisualStudio.Web.Application.Generator.UpdateDesignerClass(String document, String codeBehind, String codeBehindFile, String[] publicFields, UDC_Flags flags)
</code></pre>
<p><em>ProcessBeginTag</em> cannot map a tag to a control. The tag <em>EPiServer:Property</em> control is not registered on the page but in the <em>&lt;system.web&gt;&lt;pages&gt;&lt;controls&gt;</em> section in <em>web.config</em>. This indicates that something fails either in <em>TemplateParse.PrepareParse</em> when trying to get hold of the <em>RuntimeConfig</em> or in <em>Microsoft.VisualStudio.Web.Application.Parser.ParseConfig</em> when it tries to get to <em>web.config</em> through the designer host.</p>
<p>Adding a Register directive manually to the Page will remove the first error and reveal another.</p>
<pre><code>System.Web.HttpParseException: The expression prefix 'Resources' was not recognized.  Please correct the prefix or register the prefix in the &lt;expressionBuilders&gt; section of configuration.
<strong>   at System.Web.Compilation.ExpressionBuilder.GetExpressionBuilder(String expressionPrefix, VirtualPath virtualPath, IDesignerHost host)
</strong>   at System.Web.UI.ControlBuilder.AddBoundProperty(String filter, String name, String expressionPrefix, String expression, ExpressionBuilder expressionBuilder, Object parsedExpressionData, Boolean generated, String fieldName, String formatString, Boolean twoWayBound)
   at System.Web.UI.ControlBuilder.PreprocessAttribute(String filter, String attribname, String attribvalue, Boolean mainDirectiveMode)
   at System.Web.UI.ControlBuilder.PreprocessAttributes(ParsedAttributeCollection attribs)
   at System.Web.UI.ControlBuilder.Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String id, IDictionary attribs)
   at System.Web.UI.ControlBuilder.CreateChildBuilder(String filter, String tagName, IDictionary attribs, TemplateParser parser, ControlBuilder parentBuilder, String id, Int32 line, VirtualPath virtualPath, Type&amp; childType, Boolean defaultProperty)
   at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
</code></pre>
<p>The code in <em>GetExpressionBuilder</em> gives the same indication and strengthens my suspicion that the parser fails to get hold of any configuration at all since the <em>&lt;expressionBuilders&gt;</em> tag is in the global <em>web.config</em>.</p>
<p>I&#8217;m too tired to continue the hunt for the real reason tonight but I did test one final thing:</p>
<ol>
<li>I shut down the IIS service and close Visual Studio.</li>
<li>And then do I delete all files under &#8220;Temporary ASP.NET Files&#8221;.</li>
<li>I restart Visual Studio and re-open the Project.</li>
<li>I change Project Settings to use Visual Studio Development Server instead of IIS.</li>
<li>Finally do I click &#8220;Convert to Web Application&#8221; and this time it generates without errors…</li>
</ol>
<p>Why? Maybe you know… Please, leave a comment if you have any clues!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/11/27/generation-of-designer-file-failed/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>The mysterious problem with WebResource.axd</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/09/27/the-mysterious-problem-with-webresourceaxd/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/09/27/the-mysterious-problem-with-webresourceaxd/#comments</comments>
		<pubDate>Wed, 26 Sep 2007 22:20:27 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[WebResource.axd]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=41</guid>
		<description><![CDATA[UPDATE: Solution to WebResource.axd exception
I have tried to figure out why a customer get a strange error message on their ASP.NET web site that stops the whole site from working until you restart the whole IIS.
The exception &#8220;The WebResource.axd handler must be registered in the configuration to process this request&#8221; occurred quite randomly at first [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: </strong><a title="Permanent Link to Solution to WebResource.axd exception" rel="bookmark" href="http://blog.fredrikhaglund.se/blog/2008/08/26/solution-to-webresourceaxd-exception/"><span style="color: #006a80;"><strong>Solution to WebResource.axd exception</strong></span></a></p>
<p>I have tried to figure out why a customer get a strange error message on their ASP.NET web site that stops the whole site from working until you restart the whole IIS.</p>
<p>The exception &#8220;<em>The WebResource.axd handler must be registered in the configuration to process this request</em>&#8221; occurred quite randomly at first sight. After some investigations I found that the site usually stopped working if you called some of the pages immediately after a restart of the web application. This happens for example when you change in web.config but an unload of your <em>AppDomain</em> can be triggered by other mechanisms, too.</p>
<p>I found no clues to the cause when I searched on the error message, only a lot of question and other desperate people.</p>
<p>Looking closer at the call stack and browsning around with <a href="http://www.aisto.com/roeder/DotNet/">Roeders Reflector</a> I found that the cause of our problem with <em>WebResource.axd</em> is in the method <em>EnsureHandlerExistenceChecked</em> in the class <em>System.Web.Handlers.AssemblyResourceLoader</em>:</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/ensurehandlerexistencechecked.PNG"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/ensurehandlerexistencechecked.PNG" alt="EnsureHandlerExistenceChecked()" /></a></p>
<p>As you can see in the code above, if the test fails once it will never re-test since <em>handlerExistenceChecked</em> is <em>true </em>and the site will stop working forever.</p>
<p>This check is called for several reasons. One of them is because components like the <em>RequiredFieldValidator</em> uses the <em>ClientScriptManager</em> to insert links on the page to JavaScript that is embedded inside a resource in an assembly somewhere. To make the resource available from the browser the generated link contains a reference <em>WebResource.axd</em> that is registered as a <em>HttpHandler</em> in <em>machine.config</em><strong> </strong>redirecting calls with that filename to the <em>AssemblyResourceLoader</em> class.</p>
<p>The only way to recover from the error I have found is to stop the site, run <em>iisreset /restart</em> and wait for a while before you start the site again.</p>
<p>I have not manage to find the exact reason for why the test fails initially. I have some theories but they are hard to validate since used classes and methods are private or internal. One guess is that <em>FindMapping </em>returns null because the <em>HttpHandler </em>collection has not yet been loaded. Another guess is that <em>HttpHandlerAction </em>has not been correctly initialized so <em>TypeInternal </em>is null. It could even be possible that there is a problem with the type system (because ASP.NET applications unloads the <em>AppDomain</em>, generat assemblies dynamically and loads them, etc) so you actually have two instances of the same underlying system type making the Equal operator give an incorrect result.</p>
<p>It really does not matter why it does not work since we can not patch Microsoft&#8217;s framework ourself or wait for a hot fix. If anyone else has some clues or have done some research on this problem, please let me know!</p>
<p>My workaround to recover from the error is to use reflection to clear one of the private static flags so it re-runs the test. (Use of reflection like the requires that your application does not run with a low trust level so it might not work everywhere.) Since it is expensive to use reflection I only run the check in the <em>Error </em>event handler in my <em>Application </em>object.</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/workaround.PNG"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/workaround.PNG" alt="Source code for workaround" /></a></p>
<p>Any feedback is appreciated.</p>
<p><a href="http://fredrikhaglund.se/blog/070927/Global.asax.zip">Download example code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/09/27/the-mysterious-problem-with-webresourceaxd/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>
