<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://ljusberg.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Smöråkning</title><subtitle type="html" /><id>http://ljusberg.com/blogs/smorakning/atom.aspx</id><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/default.aspx" /><link rel="self" type="application/atom+xml" href="http://ljusberg.com/blogs/smorakning/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20611.960">Community Server</generator><updated>2007-04-22T10:01:00Z</updated><entry><title>Windows Server 2008 as development platform</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2008/06/23/windows-server-2008-as-development-platform.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2008/06/23/windows-server-2008-as-development-platform.aspx</id><published>2008-06-23T15:40:30Z</published><updated>2008-06-23T15:40:30Z</updated><content type="html">&lt;p style="margin-left:19pt;"&gt;Well, this is going to be interesting. I&amp;#39;ve spent the day installing Windows Server 2008 on my brand new laptop at work. I was inspired by &lt;a href="http://blog.deurell.net/2008/04/min-nya-utvecklarplattform-eller-att.html"&gt;&lt;span style="color:blue;text-decoration:underline;"&gt;Mikael Deurell&amp;#39;s post about using Hyper-V&lt;/span&gt;&lt;/a&gt; etc. 
&lt;/p&gt;&lt;p style="margin-left:19pt;"&gt;So far it&amp;#39;s been much easier than I expected. Pretty much all device drivers for my Compaq 8510w installed without any problems even though I&amp;#39;m using a 64-bit system.
&lt;/p&gt;&lt;p style="margin-left:19pt;"&gt; 
 &lt;/p&gt;&lt;p style="margin-left:19pt;"&gt;I also found two great blog posts that describe how to make the Windows Server 2008 experience a little more &amp;quot;Desktoppy&amp;quot;. Check out:
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/vijaysk/archive/2008/02/11/using-windows-server-2008-as-a-super-desktop-os.aspx"&gt;&lt;span style="color:blue;text-decoration:underline;"&gt;Using Windows Server 2008 as a super desktop OS&lt;/span&gt;&lt;/a&gt;
		&lt;/li&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/vijaysk/archive/2008/02/20/using-windows-server-2008-as-a-super-workstation-os-cont-d.aspx"&gt;&lt;span style="color:blue;text-decoration:underline;"&gt;Using Windows Server 2008 as a super desktop OS Continued&lt;/span&gt;&lt;/a&gt;
		&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;Also, this is an attempt at posting using Word 2007.. Let&amp;#39;s see how that works out..!&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=6080" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author></entry><entry><title>Scrum Dashboard</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2008/02/28/scrum-dashboard.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2008/02/28/scrum-dashboard.aspx</id><published>2008-02-28T22:16:00Z</published><updated>2008-02-28T22:16:00Z</updated><content type="html">&lt;p&gt;If you&amp;#39;re a fan of Scrum and Team Foundation Server you&amp;#39;ll probably want to have a look at the &lt;a class="" href="http://www.codeplex.com/scrumdashboard"&gt;Scrum Dashboard&lt;/a&gt; recently published on CodePlex by &lt;a class="" href="http://www.episerver.com/"&gt;EPiServer&lt;/a&gt;. It looks very cool but unfortunately for us it uses the &lt;a class="" href="http://www.scrumforteamsystem.com/en/default.aspx"&gt;Scrum for Team System&lt;/a&gt; templates by Conchango instead of the &amp;quot;vanilla&amp;quot; MSF Agile templates that we&amp;#39;re using. Too bad for us, but I applaud EPiServer for making this thing available to the community. Thank&amp;#39;s guys!&lt;/p&gt;
&lt;p&gt;BTW, I actually met the guy listed as Coordinator&amp;nbsp;of the project (&lt;a class="" href="http://labs.episerver.com/en/Blogs/Per/Archive/2008/2/Scrum-Dashboard/"&gt;Per Bjurström&lt;/a&gt;) on my &lt;a class="" href="http://ljusberg.se/blogs/smorakning/archive/2007/10/17/going-to-redmond.aspx"&gt;trip to Redmond&lt;/a&gt; last October - that has to be a good sign, right?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=6074" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="TFS" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/TFS/default.aspx" /><category term="Scrum" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Scrum/default.aspx" /></entry><entry><title>What's up?</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2008/02/27/what-s-up.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2008/02/27/what-s-up.aspx</id><published>2008-02-27T16:20:00Z</published><updated>2008-02-27T16:20:00Z</updated><content type="html">&lt;p&gt;I know, I know.. I&amp;#39;ve been extremely lazy lately, at least when it comes to sharing knowledge with you guys. I guess the main reason for that is that I&amp;#39;m currently on parental leave which means that my days are not really spent researching, architecting and developing as much as they are spent entertaining &lt;a href="http://ljusberg.se/photos/miranda"&gt;Miranda&lt;/a&gt;...&lt;/p&gt;
&lt;p&gt;Anyway, as you may have realized by my &lt;a title="Caching Dynamic Controls" href="http://ljusberg.se/blogs/smorakning/archive/2007/09/10/caching-dynamic-controls-in-asp-net.aspx"&gt;previous&lt;/a&gt; &lt;a title="Caching Dynamic Controls - Solution" href="http://ljusberg.se/blogs/smorakning/archive/2007/10/17/caching-dynamic-controls-in-asp-net-solution.aspx"&gt;posts&lt;/a&gt; on the subject, I&amp;#39;ve been diving into the big swamp of ASP.NET once again. Somtime mid-last year I was tasked with creating a new plattform for the web sites at Thomas Cook Northern Europe (like &lt;a href="http://ving.se/"&gt;ving.se&lt;/a&gt;, &lt;a href="http://spies.dk/"&gt;spies.dk&lt;/a&gt;, &lt;a href="http://tjaereborg.dk/"&gt;tjaereborg.dk&lt;/a&gt; and &lt;a href="http://ving.no/"&gt;ving.no&lt;/a&gt;). The platform that is currently running all our sites is quite powerful but was designed with .NET Framework 1.1 in mind which makes it a bit clumsier than it has to be. &lt;/p&gt;
&lt;p&gt;At the time, the only web site framework on offer from Microsoft was the &lt;a href="http://msdn.microsoft.com/webclientfactory"&gt;Web Client Software Factory&lt;/a&gt;. I really liked the ideas and patterns that drive the architecture of the WCSF (in pattern-talk I guess you would describe it as Model-View-Presenter combined with Application Controllers). However, it simply wasn&amp;#39;t enough for our needs. The major problem was that the Views/Presenters are to coarse. They are designed with entire pages in mind instead of being designed for User Controls (which is what we need). I also didn&amp;#39;t like the fact that the flow engine they used couldn&amp;#39;t handle multiple flows and states per session/user. A quite common scenario for us is that a user opens up several browser windows to compare different alternative trips - something that often leads to corrupt state.&lt;/p&gt;
&lt;p&gt;In the end I decided to create a framework from scratch with much of the ideas from the WCSF intact, but extended to fit our needs. Some notable features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Based on the Model-View-Presenter and Application Controller patterns.&lt;/li&gt;
&lt;li&gt;Independent modules for each area of the web site which makes it possible to develop and deploy parts of the web site without affecting the other parts.&lt;/li&gt;
&lt;li&gt;No .aspx files - pages are built up dynamically.&lt;/li&gt;
&lt;li&gt;Multiple flows per user&lt;/li&gt;
&lt;li&gt;Fully integrated URL Rewriting&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Well, if you&amp;#39;re interested I&amp;#39;ll blog some more about this. But at least now I&amp;#39;ve given you an update on what I&amp;#39;m doing..&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Update (2008-02-28)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Funny, the day after I wrote this entry, Microsoft Sweden published a &amp;quot;&lt;a class="" title="Thomas Cook" href="http://buzzfrog.blogs.com/zabrak/2008/02/thomas-cook---i.html"&gt;success story&lt;/a&gt;&amp;quot; about the project (although the story focuses more on the way we are using TFS and VS 2008 rather than the framework itself). I had no idea this article was being written, but I guess that&amp;#39;s what happens when you&amp;#39;re on parental leave.. :-)&lt;/p&gt;
&lt;p&gt;Also, you might be asking yourself &amp;quot;How on earth do you make sure that things are going in the right direction if your not in the office?&amp;quot;. Well, luckily I&amp;#39;ve been able to hand over the framework in the very good hands of my colleague Håkan (who&amp;nbsp;also gave me a lot of great advice during the first stages of the project). If you&amp;#39;ve read this far, you&amp;#39;ll certainly find his blog even more interesting, and as a bonus it&amp;#39;s available in &lt;a class="" title="Hocke" href="http://hocke.blogspot.com/"&gt;English&lt;/a&gt;&amp;nbsp;and &lt;a class="" title="Hocke" href="http://hockeswe.blogspot.com/"&gt;Swedish&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=6071" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term=".NET" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/.NET/default.aspx" /><category term="Architecture" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Architecture/default.aspx" /><category term="ASP.NET" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>How cool is this?</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/10/27/how-cool-is-this.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/10/27/how-cool-is-this.aspx</id><published>2007-10-26T23:44:00Z</published><updated>2007-10-26T23:44:00Z</updated><content type="html">I&amp;#39;m currently writing this post on the express bus to Redmond using my iPod touch and the free WiFi provided on the bus. In my book it doesn&amp;#39;t get much cooler than that!&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5906" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="Fun" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Fun/default.aspx" /></entry><entry><title>T4 editor available</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/10/26/t4-editor-available.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/10/26/t4-editor-available.aspx</id><published>2007-10-26T18:05:00Z</published><updated>2007-10-26T18:05:00Z</updated><content type="html">&lt;p&gt;It seems &lt;a class="" title="Clarius Consulting" href="http://www.clariusconsulting.net/"&gt;Clarius Consulting&lt;/a&gt; have released a beta version of a pretty nice addition to Visual Studio, at least if you&amp;#39;re working with the Guidance Automation Toolkit. The &lt;a class="" title="T4 Editor" href="http://www.t4editor.net/"&gt;T4 Editor&lt;/a&gt; will give you IntelliSense, nice&amp;nbsp;colorization etc when working with your T4 templates.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m now just waiting for them to release a version of the &lt;a class="" title="Software Factories Toolkit" href="http://www.softwarefactoriestoolkit.net/"&gt;Software Factories Toolkit&lt;/a&gt; that works with VS2008 Beta 2..!&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5905" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="Visual Studio" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Visual+Studio/default.aspx" /><category term="GAT" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/GAT/default.aspx" /></entry><entry><title>VS2008 RTM any day now?</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/10/23/vs2008-rtm-any-day-now.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/10/23/vs2008-rtm-any-day-now.aspx</id><published>2007-10-23T04:13:00Z</published><updated>2007-10-23T04:13:00Z</updated><content type="html">&lt;p&gt;According to the Microsoft guys in building 20, the RTM of Visual Studio 2008 and .NET Framework 3.5 is coming &amp;quot;very, Very, VERY soon&amp;quot; - whatever that means... &lt;br /&gt;&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5903" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term=".NET" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/.NET/default.aspx" /><category term="Visual Studio" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Visual+Studio/default.aspx" /></entry><entry><title>Going to Redmond!</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/10/17/going-to-redmond.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/10/17/going-to-redmond.aspx</id><published>2007-10-17T14:16:00Z</published><updated>2007-10-17T14:16:00Z</updated><content type="html">&lt;p&gt;Well, in a couple of days I&amp;#39;m off to the Microsoft Campus in Redmond! I&amp;#39;m attending an Orcas Adoption Workshop next week which will take me through all the new stuff in Visual Studio 2008 and .NET Framework 3.5. So far, I haven&amp;#39;t got the agenda so I have more or less no idea who
I&amp;#39;ll meet and what kind of workshops to expect but I&amp;#39;m sure it&amp;#39;ll be
great.&lt;/p&gt;&lt;p&gt;I&amp;#39;m really, really looking forward to it. Actually visiting the Campus is something I&amp;#39;ve been dreaming about for quite some time (yes, I know.. maybe I should try to reprioritize my dreams... but still!)&amp;nbsp;&lt;/p&gt;&lt;p&gt;So, is anyone else going to be in the Redmond area next week? &lt;br /&gt;&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5899" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="Personal" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Personal/default.aspx" /><category term=".NET" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/.NET/default.aspx" /><category term="Visual Studio" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Visual+Studio/default.aspx" /></entry><entry><title>Caching dynamic controls in ASP.NET - solution</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/10/17/caching-dynamic-controls-in-asp-net-solution.aspx" /><link rel="enclosure" type="application/zip" length="9377" href="http://ljusberg.com/blogs/smorakning/attachment/5896.ashx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/10/17/caching-dynamic-controls-in-asp-net-solution.aspx</id><published>2007-10-17T07:39:00Z</published><updated>2007-10-17T07:39:00Z</updated><content type="html">&lt;p&gt;In my &lt;a href="http://ljusberg.se/blogs/smorakning/archive/2007/09/10/caching-dynamic-controls-in-asp-net.aspx"&gt;last post&lt;/a&gt;, I asked for help with a problem we&amp;#39;ve been having with caching of dynamic controls - and I got some from &lt;a title="Infinites Loop" href="http://weblogs.asp.net/infinitiesloop/default.aspx" target="_blank"&gt;Dave Reed&lt;/a&gt;. Dave works for the ASP.NET team and if his blog isn&amp;#39;t on your roll yet, add it ASAP - it&amp;#39;s simply brilliant. &lt;/p&gt;  &lt;p&gt;Dave explained the problem:&lt;/p&gt;  &lt;hr /&gt;  &lt;div&gt;Apparently, the stack trace involved with loading the control is taken into account when deciding how to cache the controls output. So for example, if you load the control twice like so: &lt;/div&gt;  &lt;pre&gt;LoadControl(&amp;quot;&lt;span style="color:#8b0000;"&gt;foo.ascx&lt;/span&gt;&amp;quot;); &lt;span style="color:#008000;"&gt;// once &lt;/span&gt;
LoadControl(&amp;quot;&lt;span style="color:#8b0000;"&gt;foo.ascx&lt;/span&gt;&amp;quot;); &lt;span style="color:#008000;"&gt;// twice&lt;/span&gt;&lt;/pre&gt;

&lt;div&gt;Then they will be cached separately. But if you load them like this:&lt;/div&gt;

&lt;pre&gt;MethodThatLoadsFoo(); &lt;span style="color:#008000;"&gt;// once &lt;/span&gt;
MethodThatLoadsFoo(); &lt;span style="color:#008000;"&gt;// twice&lt;/span&gt;&lt;/pre&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;Where MethodThatLoadsFoo contains:&lt;/div&gt;

&lt;pre&gt;LoadControl(&amp;quot;&lt;span style="color:#8b0000;"&gt;foo.ascx&lt;/span&gt;&amp;quot;); &lt;/pre&gt;

&lt;div&gt;They are cached together because it will appear that they were loaded via the same code line.&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;Since you are loading them dynamically based on data you probably have a single method that loads whatever control it is to be. But depending on the details of your implementation perhaps you can find a way to have a different LoadControl reference load each one? 
  &lt;br /&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;Ok.. So where does that leave us? Remember, the implementation that calls LoadControl in my last example looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (ControlInfo controlInfo &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; controlList)
{
   &lt;span style="color:#008000;"&gt;// Load the control and add it to the page&lt;/span&gt;
   HttpContext.Current.Items[&amp;quot;&lt;span style="color:#8b0000;"&gt;uniqueId&lt;/span&gt;&amp;quot;] = controlInfo.UniqueControlId;
   Control ctrl = LoadControl(controlInfo.ControlUrl);
   PlaceHolder1.Controls.Add(ctrl);
}&lt;/pre&gt;

&lt;p&gt;It is the same physical line of code that loads all controls, which makes the caching mechanism believe that it is the very same control that is being loaded. In order for it to cache multiple versions, I&amp;#39;d need to add a new LoadControl line for each control. So I guess I could &amp;quot;unwrap&amp;quot; the foreach-loop and do something like:&lt;/p&gt;

&lt;pre&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (controlList.Count &amp;gt; 0)
{
   HttpContext.Current.Items[&amp;quot;&lt;span style="color:#8b0000;"&gt;uniqueId&lt;/span&gt;&amp;quot;] = controlList[0].UniqueControlId;
   PlaceHolder1.Controls.Add(LoadControl(controlList[0].ControlUrl));
}
&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (controlList.Count &amp;gt; 1)
{
   HttpContext.Current.Items[&amp;quot;&lt;span style="color:#8b0000;"&gt;uniqueId&lt;/span&gt;&amp;quot;] = controlList[1].UniqueControlId;
   PlaceHolder1.Controls.Add(LoadControl(controlList[1].ControlUrl));
}
&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (controlList.Count &amp;gt; 2)
{
   HttpContext.Current.Items[&amp;quot;&lt;span style="color:#8b0000;"&gt;uniqueId&lt;/span&gt;&amp;quot;] = controlList[2].UniqueControlId;
   PlaceHolder1.Controls.Add(LoadControl(controlList[2].ControlUrl));
}&lt;/pre&gt;

&lt;p&gt;Ehh.. Nope.. Not gonna happen...&lt;/p&gt;

&lt;p&gt;The only other alternative I could think of was to dynamically generate and compile the code that is used to render a page. This is (a crude version of) what I came up with:&lt;/p&gt;

&lt;pre&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; CompileAndInitializePage(Page page, List controlList)
{
  Assembly compiledAssembly;

  &lt;span style="color:#008000;"&gt;// Has this page been built before? If so, there should already be an existing assembly&lt;/span&gt;
  &lt;span style="color:#008000;"&gt;// compiled for it.&lt;/span&gt;
  &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (compiledAssemblies.ContainsKey(page.AppRelativeVirtualPath))
  {
    compiledAssembly = compiledAssemblies[page.AppRelativeVirtualPath];
  }
  &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
  {
    &lt;span style="color:#008000;"&gt;// If not, compile a new one.&lt;/span&gt;
    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; mainHeader =
      &amp;quot;&lt;span style="color:#8b0000;"&gt;using System.Web;\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt;using System.Web.UI;\n&lt;/span&gt;&amp;quot; +

      &amp;quot;&lt;span style="color:#8b0000;"&gt;namespace DynamicCacheTest\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt;{\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt; public class TempPageBuilder\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt; {\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt; public void BuildPage(Page page)\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt; {\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt; Control holder;\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt; holder = page.FindControl(\&amp;quot;PlaceHolder1\&amp;quot;);\n&lt;/span&gt;&amp;quot;;

    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; mainFooter =
      &amp;quot;&lt;span style="color:#8b0000;"&gt; }\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt; }\n&lt;/span&gt;&amp;quot; +
      &amp;quot;&lt;span style="color:#8b0000;"&gt;}\n&lt;/span&gt;&amp;quot;;
    StringBuilder sb = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; StringBuilder(mainHeader);
    &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (ControlInfo ctrl &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; controlList)
    {
      sb.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt;HttpContext.Current.Items[\&amp;quot;uniqueId\&amp;quot;] = {0};\n&lt;/span&gt;&amp;quot;, ctrl.UniqueControlId);
      sb.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt;holder.Controls.Add(page.LoadControl(\&amp;quot;{0}\&amp;quot;));\n&lt;/span&gt;&amp;quot;, ctrl.ControlUrl);
    }
    sb.Append(mainFooter);

    ICodeCompiler compiler = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; CSharpCodeProvider().CreateCompiler();

    CompilerParameters parameters = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; CompilerParameters(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] { &amp;quot;&lt;span style="color:#8b0000;"&gt;System.dll&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style="color:#8b0000;"&gt;System.Web.dll&lt;/span&gt;&amp;quot; });
    CompilerResults res = compiler.CompileAssemblyFromSource(parameters, sb.ToString());
    compiledAssembly = res.CompiledAssembly;
    compiledAssemblies[page.AppRelativeVirtualPath] = compiledAssembly;
  }

  &lt;span style="color:#008000;"&gt;// Build the page builder object&lt;/span&gt;
  &lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; builder = Activator.CreateInstance(compiledAssembly.GetType(&amp;quot;&lt;span style="color:#8b0000;"&gt;DynamicCacheTest.TempPageBuilder&lt;/span&gt;&amp;quot;));

  &lt;span style="color:#008000;"&gt;// Invoke the BuildPage method&lt;/span&gt;
  builder.GetType().InvokeMember(&amp;quot;&lt;span style="color:#8b0000;"&gt;BuildPage&lt;/span&gt;&amp;quot;, BindingFlags.InvokeMethod, &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;, builder, &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;object&lt;/span&gt;[] { &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt; });
}&lt;/pre&gt;

&lt;p&gt;And it works beautifully! I&amp;#39;m not too worried about performance since I&amp;#39;m only compiling the page once, and running the compiled code shouldn&amp;#39;t be slower than the foreach-loop is today. The only thing I&amp;#39;m thinking is that with many pages on a site I&amp;#39;d have a lot of very small assemblies loaded. Probably it would be a better idea to precompile all pages on startup and put them in a single assembly.&lt;/p&gt;

&lt;p&gt;Anyway, in the end we&amp;#39;ve decided that we won&amp;#39;t actually put this in production since the problem probably is better worked around by educating our webmasters, but it was nice to finally find a solution.&lt;/p&gt;

&lt;p&gt;Update: I&amp;#39;ve attached the updated source code to this post. &lt;/p&gt;

&lt;p&gt;Update 2: And now I&amp;#39;m trying out a Live Writer Plugin to format the source code&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5896" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term=".NET" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/.NET/default.aspx" /><category term="ASP.NET" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>Caching dynamic controls in ASP.NET</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/09/10/caching-dynamic-controls-in-asp-net.aspx" /><link rel="enclosure" type="application/x-zip-compressed" length="7977" href="http://ljusberg.com/blogs/smorakning/attachment/5891.ashx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/09/10/caching-dynamic-controls-in-asp-net.aspx</id><published>2007-09-10T14:05:00Z</published><updated>2007-09-10T14:05:00Z</updated><content type="html">&lt;p&gt;Since the invention of partial caching in ASP.NET, we have been trying our best to implement it on our web pages. But without much luck. This post is a request, or I guess you could call it a &amp;quot;cry&amp;quot;, for help!&lt;/p&gt;&lt;p&gt;The problem is that we create all our controls dynamically, and each page can contain more than one instance of the same control (.ascx) but with different content.&lt;/p&gt;&lt;p&gt;Simply put, a page load is currently done like this:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Retrieve a list of which controls to put on the page and the unique id of the content each control should display.&lt;/li&gt;&lt;li&gt;For each control that should be created, call LoadControl and let the control know its unique id.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Each control retrieves its data by using the unique id&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Now, when trying to add partial caching to this control, the problem is that the controls are cached according to which page they&amp;#39;re on (or the query string used to get the page) and I just cannot figure out a way of caching two different instances of the same control. I mean, at the time of creation (LoadControl) I know which one I want, so it really should be theoretically possible, but I simply cannot find support for it in the API. &lt;/p&gt;&lt;p&gt;I&amp;#39;ve attached a simple test project that illustrates the problem. If you can find a nice solution, please, PLEASE let me know. I&amp;#39;d be in your debt!&lt;br /&gt;&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5891" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="ASP.NET" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/ASP.NET/default.aspx" /><category term="Help needed" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Help+needed/default.aspx" /></entry><entry><title>The new SOA</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/05/30/the-new-soa.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/05/30/the-new-soa.aspx</id><published>2007-05-30T08:15:00Z</published><updated>2007-05-30T08:15:00Z</updated><content type="html">&lt;p&gt;This is going to be confusing for me.. There&amp;#39;s a new SOA in town: &lt;a href="http://www.lotro.com/" title="LOTRO SoA" target="_blank"&gt;Lord of the Rings Online: Shadows of Angmar&lt;/a&gt; (or SoA). Let&amp;#39;s just hope they&amp;#39;ll continue to use the abbreviation &lt;a href="http://www.lotro.com/" title="Lord of the Rings Online" target="_blank"&gt;LOTRO&lt;/a&gt; instead..&lt;br /&gt;&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5876" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="Fun" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Fun/default.aspx" /><category term="Gaming" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Gaming/default.aspx" /></entry><entry><title>Online course from 2xSundblad</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/05/30/online-course-from-2xsundblad.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/05/30/online-course-from-2xsundblad.aspx</id><published>2007-05-30T07:58:00Z</published><updated>2007-05-30T07:58:00Z</updated><content type="html">&lt;p&gt;I&amp;#39;ve just looked through a part of the preview of the coming online course from &lt;a href="http://www.2xsundblad.com/" title="2xSundblad" target="_blank"&gt;2xSundblad&lt;/a&gt; called Architecting Service Oriented Systems – Overview. It&amp;#39;s Flash-based with a mix of video, audio and slides. Looks very promising and it will be available for a very reasonable $399 (if you register your interest early you&amp;#39;ll even get a 25% discount). &lt;/p&gt;&lt;p&gt;I guess you&amp;#39;ll have to get used to the Swedish accent of Sten and Per, but knowing them I can promise you it&amp;#39;ll be worth it!&lt;/p&gt;&lt;p&gt;Three other courses will be available within the next year or so:&lt;/p&gt;&lt;ul&gt;&lt;font&gt;&lt;li&gt;The Infrastructure of Shareable Information Pattern – Planning, 
Architecting, Designing, and Implementing. 
&lt;/li&gt;&lt;li&gt;The Entity Services and User Application Pattern – Planning, Architecting, 
Designing, and Implementing. 
&lt;/li&gt;&lt;li&gt;The Business Process and Use Case Services Pattern – Planning, Architecting, 
Designing, and Implementing.&lt;/li&gt;&lt;/font&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp;I&amp;#39;ll post a link to the free preview once I get an OK from Sten or Per to do so!&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;i&gt;Update&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;Here&amp;#39;s the link to the &lt;a href="http://www.2xsundblad.com/archtraining/archsosystems" title="2xSundblad"&gt;preview of 2xSundblad&amp;#39;s new online course&lt;/a&gt;.&lt;/i&gt;&lt;br /&gt;&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5875" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="SOA" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/SOA/default.aspx" /><category term="Architecture" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Architecture/default.aspx" /></entry><entry><title>The Agile pyramid</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/05/25/the-agile-pyramid.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/05/25/the-agile-pyramid.aspx</id><published>2007-05-25T07:25:00Z</published><updated>2007-05-25T07:25:00Z</updated><content type="html">&lt;p&gt;One of my favorite developer sites, &lt;a href="http://worsethanfailure.com" target="_blank"&gt;Worse Than Failure&lt;/a&gt; (used to be called The Daily WTF), just published an article about &lt;a href="http://worsethanfailure.com/Articles/The-Great-Pyramid-of-Agile.aspx" target="_blank"&gt;Agile methodologies&lt;/a&gt; and why they suck. While I don&amp;#39;t agree with Alex it&amp;#39;s always fun when an analogy is turned upside down... The problem here is that the Pyramid analogy is flawed in the first place since an extremely important part of agile methodologies, Refactoring, is missing. Instead, building a pyramid using agile methodologies would rather be done this way:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Get some initial input from the Pharaoh. It will be something like &amp;quot;I&amp;#39;d like it to look like all the other pyramids, only bigger and better&amp;quot;.&lt;/li&gt;&lt;li&gt;Start building something that may or may not look much like a pyramid.&lt;/li&gt;&lt;li&gt;Find some flaws in your design. Show the Pharaoh and ask him what he thinks of it so far.&lt;/li&gt;&lt;li&gt;Tear down everything you or the Pharaoh don&amp;#39;t like.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add some more components to the pyramid.&lt;/li&gt;&lt;li&gt;Realize that the foundation of the pyramid isn&amp;#39;t solid enough.&lt;/li&gt;&lt;li&gt;Rebuild the foundation&lt;/li&gt;&lt;li&gt;Repeat steps 3, 4 and maybe 5 and 6 until you and the Pharaoh are happy with the result.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;And this is why agile methodologies are better suited for software development than for construction work...&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5874" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="Architecture" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Architecture/default.aspx" /></entry><entry><title>Code beauty</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/05/16/code-beauty.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/05/16/code-beauty.aspx</id><published>2007-05-16T14:03:00Z</published><updated>2007-05-16T14:03:00Z</updated><content type="html">&lt;p&gt;It&amp;#39;s pretty clear that there are two basic kinds of developers; those that write code only to get the job done, and those that write code which in addition to getting the job done also looks good. I&amp;#39;m definitely part of the latter group and I have to say that sometimes I get frustrated when working with developers of the former conviction.&lt;/p&gt;&lt;p&gt;I was just reviewing some code written in a project I haven&amp;#39;t been involved in much, and found a set of very commonly used classes that lie in a namespace that is misspelled. I realize this doesn&amp;#39;t matter. I mean, the code does exactly what it&amp;#39;s supposed to do and the misspelling is so simple that everyone understands what it was meant to be called. But c&amp;#39;mon! Correcting the mistake would take about 2 minutes thanks to the refactoring functionality in Visual Studio.&lt;/p&gt;&lt;p&gt;Now to the difficult question... Should I mention it in my review?&lt;br /&gt;&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5868" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="Architecture" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Architecture/default.aspx" /></entry><entry><title>Enterprise Library 3.0 available</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/05/08/enterprise-library-3-0-available.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/05/08/enterprise-library-3-0-available.aspx</id><published>2007-05-08T08:20:00Z</published><updated>2007-05-08T08:20:00Z</updated><content type="html">&lt;p&gt;Can&amp;#39;t believe I almost missed this completely! Turns out the P&amp;amp;P team released &lt;a href="http://msdn2.microsoft.com/en-us/library/aa480453.aspx" title="Enterprise Library" target="_blank"&gt;Enterprise Library 3.0&lt;/a&gt; the other day. For me, the two most interesting new features have to be Environmental overrides and the new Validation Application Block. I&amp;#39;m also very happy to see a rolling trace file listener included in the Logging Application Block - I checked our production servers the other day, and some of the logfiles where a couple of gigabytes each.. not good.. not good at all..&lt;br /&gt;&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5865" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term=".NET" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/.NET/default.aspx" /><category term="Enterprise Library" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Enterprise+Library/default.aspx" /></entry><entry><title>Community Server 2007</title><link rel="alternate" type="text/html" href="http://ljusberg.com/blogs/smorakning/archive/2007/04/22/community-server-2007.aspx" /><id>http://ljusberg.com/blogs/smorakning/archive/2007/04/22/community-server-2007.aspx</id><published>2007-04-22T08:01:00Z</published><updated>2007-04-22T08:01:00Z</updated><content type="html">&lt;p&gt;The guys over at &lt;a class="" title="Telligent" href="http://telligent.com/" target="_blank"&gt;Telligent&lt;/a&gt; released the much longed for new version of &lt;a class="" title="Community Server 2007" href="http://communityserver.org/blogs/announcements/archive/2007/04/16/community-server-2007-released.aspx" target="_blank"&gt;Community Server&lt;/a&gt;. And they did it right on schedule! Very impressive!&lt;/p&gt;
&lt;p&gt;I spent a couple of hours yesterday upgrading my 2.1 installation and it all went pretty smoothly. Haven&amp;#39;t checked out the new theme engine yet, but maybe I&amp;#39;ll get around to that.&lt;/p&gt;&lt;img src="http://ljusberg.com/aggbug.aspx?PostID=5516" width="1" height="1"&gt;</content><author><name>anders</name><uri>http://ljusberg.com/members/anders.aspx</uri></author><category term="Community Server" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Community+Server/default.aspx" /><category term="Blogging" scheme="http://ljusberg.com/blogs/smorakning/archive/tags/Blogging/default.aspx" /></entry></feed>