<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Alik Levin's : Planning Phase</title><link>http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx</link><description>Tags: Planning Phase</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>ASP.NET Performance By Design: Takeaways From PDC</title><link>http://blogs.msdn.com/alikl/archive/2008/11/03/asp-net-performance-by-design-takeaways-from-pdc.aspx</link><pubDate>Mon, 03 Nov 2008 12:06:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9032152</guid><dc:creator>alikl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/alikl/comments/9032152.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=9032152</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=9032152</wfw:comment><description>&lt;table cellspacing="5" cellpadding="2" width="557" border="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="226"&gt;&amp;#160;&lt;a href="http://practicethis.com/" target="_blank"&gt;&lt;img title="Alik Levin" height="50" alt="Alik Levin" src="http://blogs.microsoft.co.il/blogs/mcs/WindowsLiveWriter/d20b00ba5cce_FD44/image_5.png" width="50" border="0" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160; During PDC, there were 5 dedicated sessions for improving performance in .Net titled &amp;quot;Performance By Design&amp;quot;. The presenters are &lt;a href="http://blogs.msdn.com/ricom"&gt;Rico Mariani&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/vancem/"&gt;Vance Morrison&lt;/a&gt;, and Mark Friedman. These guys live and breathe performance. Although I did not make to get to PDC, I was following after what's going on there. Fortunately, Vance published all slides on his blog. These are my takeaways from the slides he published.&lt;/td&gt;        &lt;td valign="top" width="314"&gt;&lt;script type="text/javascript"&gt;


 
&lt;!-- 
lqm_channel=1;
lqm_publisher=253;
lqm_zone=1;
lqm_format=6;
//--&gt;&lt;/script&gt;&lt;script src="http://a.lakequincy.com/s.js" type="text/javascript"&gt;&lt;/script&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/vancem/archive/2008/10/30/slides-for-pdc-2008-talk-performance-by-design-rico-mariani-s-introduction.aspx"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://blogs.msdn.com/vancem/archive/2008/10/30/slides-for-pdc-2008-talk-performance-by-design-rico-mariani-s-introduction.aspx"&gt;Performance by Design Intro&lt;/a&gt; &lt;/h3&gt;  &lt;p&gt;&lt;em&gt;By Rico Mariani&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;My favorite is the first slide that sets the expectations - Performance is about Culture:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Part 1 - Teaching Performance Culture &lt;/li&gt;    &lt;li&gt;Part 2 - General Topics about Managed Code &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I am so happy to see it!&amp;#160; There is a perception about performance in the field - it is about tools. There is another perception - &amp;quot;we can fix performance after we build the app&amp;quot;. I've been through few situations where such approach resulted in extra budget to &amp;quot;fix the performance issues&amp;quot;, missed deadlines, and frustrated customers (and stakeholders). Rico says there are very few rules to follow:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Rule #1 - Measure&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Rule #2 - Do your homework&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Rico explains P&lt;strong&gt;&lt;em&gt;erformance Culture&lt;/em&gt;&lt;/strong&gt; very simply but in powerful way:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Budget. &lt;/strong&gt;An exercise to assess the value of a new feature and the cost you&amp;#8217;d be willing to pay:       &lt;ul&gt;       &lt;li&gt;Begin by thinking about how the customer thinks about performance          &lt;ul&gt;           &lt;li&gt;Responsiveness &lt;/li&gt;            &lt;li&gt;Capacity &lt;/li&gt;            &lt;li&gt;Throughput &lt;/li&gt;            &lt;li&gt;Cost of Entry &lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;        &lt;li&gt;Identify the resource the customer views as critical to this system &lt;/li&gt;        &lt;li&gt;Choose the level of performance we want to deliver (do we need an &amp;#8220;A+&amp;#8221; or is a &amp;#8220;D&amp;#8221; good enough) &lt;/li&gt;        &lt;li&gt;Convert this into what resource usage needs to be to succeed &lt;/li&gt;        &lt;li&gt;Don&amp;#8217;t think about the code, think about the customer &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Plan. &lt;/strong&gt;Validate your design against the budget, this is a risk assessment       &lt;ul&gt;       &lt;li&gt;You can&amp;#8217;t plan without a budget, so get one &lt;/li&gt;        &lt;li&gt;Use best practices to select candidate algorithms &lt;/li&gt;        &lt;li&gt;Understand their costs in terms of the critical resource &lt;/li&gt;        &lt;li&gt;Identify your dependencies and understand their costs &lt;/li&gt;        &lt;li&gt;Compare these projected costs against the budgets &lt;/li&gt;        &lt;li&gt;If you are close to budget you will need much greater detail in your plans &lt;/li&gt;        &lt;li&gt;Identify verification steps and places to abort if it goes badly &lt;/li&gt;        &lt;li&gt;Proceed when you are comfortable with the risk &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Verify.&lt;/strong&gt; Measure the final results, discard failures without remorse or penalty, don&amp;#8217;t make us live with them       &lt;ul&gt;       &lt;li&gt;The budget and the plan drive verification steps &lt;/li&gt;        &lt;li&gt;Performance that cannot be verified does not exist &lt;/li&gt;        &lt;li&gt;Don&amp;#8217;t be afraid to cancel features that are not meeting their budgets &amp;#8211; we expect to lose some bets &lt;/li&gt;        &lt;li&gt;Don&amp;#8217;t inflict bad performance on the world &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Bottom line - performance is about culture - tools only support it. Performance cost you either way - either you invest in it or not. Manage it as you'd manage any other risk.&lt;/p&gt;  &lt;h4&gt;My Related Posts&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/ace_team/archive/2008/03/11/improve-net-applications-performance-effectively-and-efficiently.aspx"&gt;Improve .Net Applications Performance Effectively And Efficiently&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/06/20/performance-testing-objectives-document-template.aspx"&gt;Performance Testing Objectives Document Template&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/05/05/asp-net-performance-engineering-stress-test-your-architecture-design-and-code.aspx"&gt;ASP.NET Performance Engineering - Stress Test Your Architecture, Design, And Code&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;&lt;a href="http://blogs.msdn.com/vancem/archive/2008/10/30/slides-for-pdc-2008-talk-performance-by-design-measuring-cpu-time.aspx"&gt;CPU Optimization for .NET Applications&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;em&gt;By Vance Morrison&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Vance supports Rico's Rule #1 - Measure. He provides several practical options:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Low Tech: System.Diagnostics.Stopwatch &lt;/li&gt;    &lt;li&gt;Medium Tech: &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc507639.aspx"&gt;MeasureIt&lt;/a&gt; (Automates Stopwatch) &lt;/li&gt;    &lt;li&gt;Medium Tech: Use ETW (Event Tracing for Windows) &lt;/li&gt;    &lt;li&gt;Higher Tech: Sample Based Profiling. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Vance admits that ETW (Event Tracing for Windows)&amp;#160; &amp;quot;...is not easy to use End-to-End: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We are working it &lt;/li&gt;    &lt;li&gt;We will have more offerings in next release &lt;/li&gt;    &lt;li&gt;It is a complete talk just by itself &lt;/li&gt;    &lt;li&gt;If you need logging NOW you CAN use EventProvider, xperf &lt;/li&gt;    &lt;li&gt;If you can wait a year, it will be significantly nicer.&amp;#160; &lt;/li&gt;    &lt;li&gt;If there is interest, we can have an &amp;#8216;Open Space&amp;#8217; discussion&amp;quot; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;My biggest takeaway from this session is that I know unforgivably too little about &lt;a href="http://www.microsoft.com/whdc/system/sysperf/perftools.mspx"&gt;ETW&lt;/a&gt; - need to ramp up myself on it.&lt;/p&gt;  &lt;h4&gt;My Related Posts&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/ace_team/archive/2008/08/11/asp-net-performance-high-cpu-utilization-case-studies-and-solutions.aspx"&gt;ASP.NET Performance: High CPU Utilization Case Studies And Solutions&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;&lt;a href="http://blogs.msdn.com/vancem/archive/2008/10/30/slides-for-pdc-2008-talk-performance-by-design-measuring-memory.aspx"&gt;Memory Optimization for .NET Applications&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;em&gt;By Vance Morrison&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;My favorite slide is #14:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;quot;Fixing Memory Issues: Prevention!&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Fixing Memory Issues is HARD      &lt;ul&gt;       &lt;li&gt;Usually a DESIGN problem: Not Pay for Play &lt;/li&gt;        &lt;li&gt;Using every new feature in your app          &lt;br /&gt;XML, LINQ, WPF, WCF, Serialization, Winforms, &amp;#8230; &lt;/li&gt;        &lt;li&gt;Initialize all subsystems at startup &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;GC Memory Are your Data Structures      &lt;ul&gt;       &lt;li&gt;Tend to be designed early &lt;/li&gt;        &lt;li&gt;Hard to change later &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Thus it Pays to Think about Memory Early!&amp;quot; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;What does it mean to think about memory early? The slide deck is packed with explanation about the measurement tools and the theory behind GC. I'd also expect to see few code samples - both patterns and anti-patterns. &lt;a href="http://blogs.msdn.com/ricom/archive/2003/12/04/41281.aspx"&gt;Mid-life crisis&lt;/a&gt; drill down would work for me.&lt;/p&gt;  &lt;h4&gt;My Related Posts&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/10/08/asp-net-performance-dynamically-loaded-assemblies-cause-application-recycles-problem-and-solution.aspx"&gt;ASP.NET Performance: Dynamically Loaded Assemblies Cause Application Recycles (Problem and Solution)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/07/31/best-asp-net-performance-winner-for-data-binding-hands-up-to-response-write.aspx"&gt;Best ASP.NET Performance Winner For Data Binding - Hands Up To Response.Write()&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;&lt;a href="http://blogs.msdn.com/vancem/archive/2008/10/30/slides-for-pdc-2008-talk-performance-by-design-parrallel-programming.aspx"&gt;Parallelism for .NET Applications&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;em&gt;By Vance Morrison&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;The only takeaway (beside good tips) is that Parallel Computing is getting into mainstream. From the field I see more and more demand for multithreaded work, I observe customers buying strong servers but do not utilize it to its capacity while asking to improve performance. I liked the structure of the session, especially &amp;quot;How .Net Can Help...&amp;quot; slides that offer practical tips and implementation suggestions to improve performance by parallelism. &lt;/p&gt;  &lt;h4&gt;My Related Post&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/10/02/improve-asp-net-2-0-performance-with-pageasynctask-multithreading-for-the-masses.aspx"&gt;Improve ASP.NET 2.0 Performance With PageAsyncTask - Multithreading For The Masses&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/06/20/pitfalls-with-net-multithreading-and-com-objects-threads-must-have-compatible-apartment-models-mta-vs-sta.aspx"&gt;Pitfalls With .Net Multithreading And COM Objects &amp;#8211; Threads Must Have Compatible Apartment Models (MTA vs. STA)&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;&lt;a href="http://blogs.msdn.com/vancem/archive/2008/10/30/slides-for-pdc-2008-talk-performance-by-design-asp-net-performance.aspx"&gt;ASP.NET Web Application Performance&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;em&gt;By Mark Friedman&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;This is really huge slide deck - 110 slides... that covers tons of stuff. &lt;/p&gt;  &lt;p&gt;I was looking for unusual stuff. I found it. Turns out &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=119F3477-DCED-41E3-A0E7-D8B5CAE893A3&amp;amp;displaylang=en"&gt;Visual Round Trip Analyzer&lt;/a&gt; (VRTA) was released to the web. The tool was internal for some time and now it is&amp;#160; available for the masses. Good news!&lt;/p&gt;  &lt;p&gt;I also liked the slides about ETW for IIS. Especially the ETW Trace reporting tool , which is Excel ;). One statement made me feel alert - &amp;quot;Caching the same data in multiple places tends to be wasteful&amp;quot;. Not the statement itself rather the relation to &lt;a href="http://msdn.microsoft.com/en-us/data/cc655792.aspx"&gt;Velocity&lt;/a&gt;, which is MS distributed cache mechanism. Need to dig deeper. Overall, the slide deck is packed with very useful and practical recommendations spanning multiple technologies like ASP.NET, AJAX, and WCF.&lt;/p&gt;  &lt;h4&gt;My Related Posts&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/10/29/asp-net-performance-fast-ajax-faster-ajax.aspx"&gt;ASP.NET Performance: Fast AJAX, Faster AJAX&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/02/18/how-to-consume-wcf-using-ajax-without-asp-net.aspx"&gt;How To Consume WCF Using AJAX Without ASP.NET&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/12/31/asp-net-ajax-control-toolkit-basic-sample-for-dynamicpopulate-control.aspx"&gt;ASP.NET AJAX Control Toolkit - Basic Sample For DynamicPopulate Control&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;a onclick="window.location = &amp;#39;http://www.reddit.com/submit?url=&amp;#39; + encodeURIComponent(window.location); return false" href="http://www.reddit.com/submit"&gt;&lt;img alt="submit to reddit" src="http://www.reddit.com/static/spreddit11.gif" border="0" /&gt; &lt;/a&gt;  &lt;p&gt;&lt;strong&gt;This template is made with &lt;a href="http://practicethis.com/" target="_blank"&gt;PracticeThis.com&lt;/a&gt; plugin for Windows Live Writer&lt;/strong&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9032152" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Practices/default.aspx">Practices</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item><item><title>ASP.NET Data Binding Performance – Collection Is More Expensive Than Datatable</title><link>http://blogs.msdn.com/alikl/archive/2008/08/01/ASP.NET-Data-Binding-Performance-_1320_-Collection-Is-More-Expensive-Than-Datatable.aspx</link><pubDate>Fri, 01 Aug 2008 14:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8794452</guid><dc:creator>alikl</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8794452.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8794452</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8794452</wfw:comment><description>&lt;A href="http://practicethis.com/" target=_blank mce_href="http://practicethis.com/"&gt;&lt;IMG title="Alik Levin" height=50 alt="Alik Levin" src="http://blogs.microsoft.co.il/blogs/mcs/WindowsLiveWriter/d20b00ba5cce_FD44/image_5.png" width=50 border=0 mce_src="http://blogs.microsoft.co.il/blogs/mcs/WindowsLiveWriter/d20b00ba5cce_FD44/image_5.png"&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; In my previous post -&amp;nbsp; &lt;A href="http://blogs.msdn.com/alikl/archive/2008/07/31/best-asp-net-performance-winner-for-data-binding-hands-up-to-response-write.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2008/07/31/best-asp-net-performance-winner-for-data-binding-hands-up-to-response-write.aspx"&gt;Best ASP.NET Performance Winner For Data Binding - Hands Up To Response.Write()&lt;/A&gt; – I’ve conducted several simple performance tests for data binding to GridView in ASP.NET page. What surprised me most is that eliminating massive loops and collection enumerations did not help in reducing CPU utilization. When we measured the execution times for both scenarios, DataBind() method revealed the secret. 
&lt;H3&gt;Reporting Execution Times&lt;/H3&gt;
&lt;P&gt;We used System.Diagnostics.Trace to report execution times.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;UseCustomCollection.aspx.cs&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; System.Diagnostics.Trace.WriteLine(&lt;SPAN style="COLOR: #006080"&gt;"1. STARTING"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt; DataGrid datagrid = SampleServices.GenerateDynamicDataGridControl();&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.Controls.Add(datagrid);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt; System.Diagnostics.Trace.WriteLine(&lt;SPAN style="COLOR: #006080"&gt;"2. GRID CREATED AND ADDED TO PAGE"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt; MyCollection myCollection = (MyCollection)SampleServices.GenerateCollection(200);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt; System.Diagnostics.Trace.WriteLine(&lt;SPAN style="COLOR: #006080"&gt;"3. CUSTOM COLLECTION CREATED"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt; datagrid.DataSource = myCollection;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt; datagrid.DataBind();&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt; System.Diagnostics.Trace.WriteLine(&lt;SPAN style="COLOR: #006080"&gt;"5. DONE"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;UseDataTable.aspx.cs&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; System.Diagnostics.Trace.WriteLine(&lt;SPAN style="COLOR: #006080"&gt;"1. STARTING"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt; DataGrid datagrid = SampleServices.GenerateDynamicDataGridControl();&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.Controls.Add(datagrid);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt; System.Diagnostics.Trace.WriteLine(&lt;SPAN style="COLOR: #006080"&gt;"2. GRID CREATED AND ADDED TO PAGE"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt; MyCollection myCollection = (MyCollection)SampleServices.GenerateCollection(200);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt; System.Diagnostics.Trace.WriteLine(&lt;SPAN style="COLOR: #006080"&gt;"3. CUSTOM COLLECTION CREATED"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt; DataTable datatable = SampleServices.ConvertCollectionTableIntoDataTalbe(myCollection);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt; System.Diagnostics.Trace.WriteLine(&lt;SPAN style="COLOR: #006080"&gt;"4. CUSTOM COLLECTION CONVERTED INTO DATATABLE"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  16:&lt;/SPAN&gt; datagrid.DataSource = datatable;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  17:&lt;/SPAN&gt; datagrid.DataBind();&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  18:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;  19:&lt;/SPAN&gt; System.Diagnostics.Trace.WriteLine(&lt;SPAN style="COLOR: #006080"&gt;"5. DONE"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, that &lt;STRONG&gt;UseCustomCollection.aspx.cs&lt;/STRONG&gt; misses step “4. CUSTOM COLLECTION CONVERTED INTO DATATABLE”. &lt;/P&gt;
&lt;H3&gt;Collecting Execution Times&lt;/H3&gt;
&lt;P&gt;We used &lt;A href="http://blogs.msdn.com/alikl/archive/2007/07/16/use-sysinternals-debugview-to-diagnose-the-application.aspx" target=_blank mce_href="http://blogs.msdn.com/alikl/archive/2007/07/16/use-sysinternals-debugview-to-diagnose-the-application.aspx"&gt;DebugView&lt;/A&gt; to collect reported execution times.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Testpost_13B58/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Testpost_13B58/image_2.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=209 alt=image src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Testpost_13B58/image_thumb.png" width=539 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Testpost_13B58/image_thumb.png"&gt;&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;H3&gt;Analysis&lt;/H3&gt;
&lt;P&gt;Applying simple mathematics we can see that converting Collection to Datatable takes 0.00081015 seconds.&amp;nbsp; This is the gain we get when skipping this step in &lt;STRONG&gt;UseCustomCollection.aspx.cs&lt;/STRONG&gt;. &lt;/P&gt;
&lt;P&gt;Now lets examine DataBind() in both cases:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;UseCustomCollection.aspx.cs &lt;/STRONG&gt;0.00268023 seconds &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;UseDataTable.aspx.cs&lt;/STRONG&gt; 0.00215912 seconds &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;I know it is not a huge improvement for binding datatable vs. collection, but the tests we conducted always showed this gap. That is why eliminating the type transformation from collection to datatable that included enumeration and looping did not really help and we ended up with similar results of ~65% CPU utilization:&lt;/P&gt;
&lt;TABLE class="" cellSpacing=5 cellPadding=2 width=400 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=200&gt;&lt;STRONG&gt;UseDataTable.aspx&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=200&gt;&lt;STRONG&gt;UseCustomCollection.aspx&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=200&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_2.png"&gt;&lt;IMG title=image height=372 alt=image src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_thumb.png" width=225 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_thumb.png"&gt;&lt;/A&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=200&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_4.png"&gt;&lt;IMG title="ASP.NET Data Binding Performance" height=369 alt="ASP.NET Data Binding Performance" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_thumb_1.png" width=241 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_thumb_1.png"&gt;&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;H3&gt;Conclusion&lt;/H3&gt;
&lt;P&gt;Binding custom collection is expensive performance wise since internally it uses reflection and reflection is expensive thing to do. Looping is expensive performance wise too but it is cheaper than reflection. &lt;/P&gt;
&lt;H3&gt;Related Materials&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2008/07/20/use-free-tools-from-iis-resource-kit-to-warm-up-your-asp-net-1-1-application-by-batch-compilation.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2008/07/20/use-free-tools-from-iis-resource-kit-to-warm-up-your-asp-net-1-1-application-by-batch-compilation.aspx"&gt;Use FREE Tools From IIS Resource Kit To Warm Up Your ASP.NET 1.1 Application By Batch Compilation&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2008/05/05/asp-net-performance-engineering-stress-test-your-architecture-design-and-code.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2008/05/05/asp-net-performance-engineering-stress-test-your-architecture-design-and-code.aspx"&gt;ASP.NET Performance Engineering - Stress Test Your Architecture, Design, And Code&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2008/04/28/performance-sin-chatty-database-access-and-loops-plus-another-free-performance-tool.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2008/04/28/performance-sin-chatty-database-access-and-loops-plus-another-free-performance-tool.aspx"&gt;Performance Sin - Chatty Database Access And Loops (Plus Another Free Performance Tool)&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2008/03/09/stress-test-asp-net-web-application-with-free-wcat-tool.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2008/03/09/stress-test-asp-net-web-application-with-free-wcat-tool.aspx"&gt;Stress Test ASP.NET Web Application With Free WCAT Tool&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2008/01/21/performance-code-review-tool-practices-checker.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2008/01/21/performance-code-review-tool-practices-checker.aspx"&gt;Performance Code Review Tool – Practices Checker&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8794452" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item><item><title>Best ASP.NET Performance Winner For Data Binding - Hands Up To Response.Write()</title><link>http://blogs.msdn.com/alikl/archive/2008/07/31/best-asp-net-performance-winner-for-data-binding-hands-up-to-response-write.aspx</link><pubDate>Thu, 31 Jul 2008 15:29:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8793251</guid><dc:creator>alikl</dc:creator><slash:comments>21</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8793251.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8793251</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8793251</wfw:comment><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://practicethis.com/" target="_blank"&gt;&lt;img title="Alik Levin" height="50" alt="Alik Levin" src="http://blogs.microsoft.co.il/blogs/mcs/WindowsLiveWriter/d20b00ba5cce_FD44/image_5.png" width="50" border="0" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; To achieve best performance you need to make decisions based on trade-off between coolness, coding productivity, and personal engineering values. I never thought I would be recommending my customer considering using old fashion Response.Write() in his Internet facing ASP.NET web application in order to significantly improve the application’s performance. &lt;/p&gt;  &lt;h3&gt;Customer Case Study&lt;/h3&gt;  &lt;p&gt;During load/stress testing customer’s ASP.NET web application we identified high CPU utilization (up to 90%). After quick investigation we noticed that &lt;strong&gt;%Time in GC&lt;/strong&gt; performance counter is less than optimal. Our assumption was that the application uses memory allocation techniques that are less than optimal. From &lt;a href="http://blogs.msdn.com/maoni/archive/2004/06/03/148029.aspx" target="_blank"&gt;GC Performance Counters&lt;/a&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;quot;First thing you may want to look at is &lt;b&gt;“% Time in GC”&lt;/b&gt;... What is a health value for this counter? It’s hard to say. It depends on what your app does. But if you are seeing a really high value (like 50% or more) then it’s a reasonable time to look at what’s going on inside of the managed heap.&amp;quot;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Another resource we used is timeless patterns &amp;amp; practices’ Chapter &lt;a href="http://msdn.microsoft.com/en-us/library/ms998579.aspx" target="_blank"&gt;15 — Measuring .NET Application Performance&lt;/a&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;.&lt;b&gt;NET CLR Memory\% Time in GC&lt;/b&gt;&lt;/p&gt;    &lt;p&gt;&amp;quot;…The most common cause of a high value is making too many allocations, which may be the case if you are allocating on a per-request basis for ASP.NET applications. You need to study the allocation profile for your application if this counter shows a higher value.&amp;quot; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So we headed to looking into the code and this is what we found out.&lt;/p&gt;  &lt;h3&gt;Analysis&lt;/h3&gt;  &lt;p&gt;During &lt;a href="http://msdn.microsoft.com/en-us/library/ms998574.aspx" target="_blank"&gt;performance code inspection&lt;/a&gt; we identified massive usage of collections. The collections were used to transfer the data between the logical layers and then the collections were transferred into datatables to be bindable for DataGrid (yes, it is .Net 1.1 app). &lt;/p&gt;  &lt;p&gt;Eureka! We just spotted 3 performance anti-patterns. Massive memory allocation, massive loops, massive type conversions. I’ve shown it to 4 very respected professionals and everyone was saying the same – current situation is pure performance anti-pattern. Here are few suggestions that came up:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Bind collections directly to DataGrid eliminating additional memory allocations and loops. &lt;/li&gt;    &lt;li&gt;Create Datatable directly from XML skipping collection creation step eliminating additional memory allocations and loops. &lt;/li&gt;    &lt;li&gt;Use Xslt transformation transforming original Xml into Html table using Xslt elminating memory allocations and loops for both collections and datatables. &lt;/li&gt;    &lt;li&gt;Use Response.Write() as it’s suggested by &lt;a href="http://msdn.microsoft.com/en-us/library/ms998549.aspx" target="_blank"&gt;patterns &amp;amp; practices&lt;/a&gt;: &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;quot;Use the &lt;b&gt;Response.Write&lt;/b&gt; method. It is one of the fastest ways to return output back to the browser.&amp;quot;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Case close? Not really...&lt;/p&gt;  &lt;p&gt;Secretly I’ve built Visual Studio 2003 project with these implementations and ran simple stress test using &lt;a href="http://blogs.msdn.com/alikl/archive/2008/07/20/use-free-tools-from-iis-resource-kit-to-warm-up-your-asp-net-1-1-application-by-batch-compilation.aspx" target="_blank"&gt;TinyGet&lt;/a&gt; utility. The results left us all a bit surprised.&lt;/p&gt;  &lt;h3&gt;Converting Collection To Datatable (Current Situation)&lt;/h3&gt;  &lt;p&gt;&lt;strong&gt;The code:&lt;/strong&gt;&lt;/p&gt;  &lt;div&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;//create custom collection&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; MyCollection myCollection = (MyCollection)SampleServices.GenerateCollection(200);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; &lt;span style="color: #008000"&gt;//convert collection to datatable&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; DataTable datatable = SampleServices.ConvertCollectionTableIntoDataTalbe(myCollection);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt; &lt;span style="color: #008000"&gt;//bind datatalbe to dynamically created datagrid&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt; datagrid.DataSource = datatable;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt; datagrid.DataBind();&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;&lt;strong&gt;The stress test:&lt;/strong&gt;&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;tinyget.exe&amp;#160; -srv:192.168.50.68 -uri:/dynamiccontrolsloadingrelease/UseDataTable.aspx -loop:100 -threads:15&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;&lt;strong&gt;The result:&lt;/strong&gt;&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_2.png"&gt;&lt;img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="353" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_thumb.png" width="213" border="0" /&gt;&lt;/a&gt; &lt;/div&gt;

&lt;h3&gt;Bind Collection Directly To Grid&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The code:&lt;/strong&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; MyCollection myCollection = (MyCollection)SampleServices.GenerateCollection(200);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #008000"&gt;//bind datatalbe to dynamically created datagrid&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; datagrid.DataSource = myCollection;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; datagrid.DataBind();&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The stress test:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;tinyget.exe&amp;#160; -srv:192.168.50.68 -uri:/dynamiccontrolsloadingrelease/UseCustomCollection.aspx -loop:100 -threads:15&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The result:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_4.png"&gt;&lt;img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="372" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_thumb_1.png" width="243" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;Create Datatable From Xml&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The code:&lt;/strong&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; xml = SampleServices.GenerateXml(200);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; StringReader theReader = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; StringReader(xml);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; DataSet theDataSet = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataSet();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; theDataSet.ReadXml(theReader);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;  &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt; datagrid.DataSource = theDataSet.Tables[0].DefaultView;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt; datagrid.DataBind();&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The stress test:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;tinyget.exe&amp;#160; -srv:192.168.50.68 -uri:/dynamiccontrolsloadingrelease/LoadXmlIntoDataTable.aspx -loop:100 -threads:15 &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The result:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_6.png"&gt;&lt;img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="434" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_thumb_2.png" width="279" border="0" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;

&lt;h3&gt;Use Xslt Transformation To Create Html Table&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The code:&lt;/strong&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; Xml1.DocumentContent = SampleServices.GenerateXml(200);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; Xml1.TransformSource=&lt;span style="color: #006080"&gt;@&amp;quot;xsl.xml&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The stress test:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;tinyget.exe&amp;#160; -srv:192.168.50.68 -uri:/dynamiccontrolsloadingrelease/XmlXslTransformation.aspx -loop:100 -threads:15 &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The result:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_8.png"&gt;&lt;img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="308" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_thumb_3.png" width="245" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;Use Response.Write()&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The code:&lt;/strong&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; MyCollection myCollection = (MyCollection)SampleServices.GenerateCollection(200);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #008000"&gt;// Put user code to initialize the page here&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; Response.Write(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;table&amp;gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt;(MyModelItem item &lt;span style="color: #0000ff"&gt;in&lt;/span&gt;  myCollection)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     Response.Write(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;tr&amp;gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     Response.Write(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt; +  item.Address  + &lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     Response.Write(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt; +  item.City  + &lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;     Response.Write(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt; +  item.Education+ &lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     Response.Write(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt; +  item.Family  + &lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;     Response.Write(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt; +  item.Name  + &lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;     Response.Write(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;/tr&amp;gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt; }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt; Response.Write(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;/table&amp;gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The stress test:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;tinyget.exe&amp;#160; -srv:192.168.50.68 -uri:/dynamiccontrolsloadingrelease/ResponseWrite.aspx -loop:100 -threads:15 &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The result:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_10.png"&gt;&lt;img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="219" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/c1810fdf4ec4_8814/image_thumb_4.png" width="227" border="0" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;

&lt;h3&gt;Sample Visual Studio 2003 Project&lt;/h3&gt;

&lt;p&gt;Interested in testing it yourself? Grab the source code from my SkyDrive &lt;a href="http://cid-dd25b83e4ca261f7.skydrive.live.com/self.aspx/Visual%20Studio%20Projects/DynamicControlsLoading.zip" target="_blank"&gt;here&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;iframe style="border-right: #dde5e9 1px solid; padding-right: 0px; border-top: #dde5e9 1px solid; padding-left: 0px; padding-bottom: 0px; margin: 3px; border-left: #dde5e9 1px solid; width: 240px; padding-top: 0px; border-bottom: #dde5e9 1px solid; height: 66px; background-color: #ffffff" marginwidth="0" marginheight="0" src="http://cid-dd25b83e4ca261f7.skydrive.live.com/embedrowdetail.aspx/Visual%20Studio%20Projects/DynamicControlsLoading.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;After conducting this simple test these are the conclusions I’ve made:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;“Don't be afraid to challenge the pros, even in their own backyard.&amp;quot; - &lt;a href="http://jtaylorgoodlife.blogspot.com/2007/06/how-to-get-things-done-colin-powell.html" target="_blank"&gt;How to Get Things Done - Colin Powell Version&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;Testing IS DA thing. Assumptions are good but nothing speaks louder than facts. &lt;/li&gt;

  &lt;li&gt;Test early - avoid massive rework afterwards. Create POC's (Proof of concept) early in architecture/design stages. &lt;/li&gt;

  &lt;li&gt;Best performance comes on expense of productivity and coolness. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Related Materials&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/07/20/use-free-tools-from-iis-resource-kit-to-warm-up-your-asp-net-1-1-application-by-batch-compilation.aspx"&gt;Use FREE Tools From IIS Resource Kit To Warm Up Your ASP.NET 1.1 Application By Batch Compilation&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/05/05/asp-net-performance-engineering-stress-test-your-architecture-design-and-code.aspx"&gt;ASP.NET Performance Engineering - Stress Test Your Architecture, Design, And Code&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/04/28/performance-sin-chatty-database-access-and-loops-plus-another-free-performance-tool.aspx"&gt;Performance Sin - Chatty Database Access And Loops (Plus Another Free Performance Tool)&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/03/09/stress-test-asp-net-web-application-with-free-wcat-tool.aspx"&gt;Stress Test ASP.NET Web Application With Free WCAT Tool&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/01/21/performance-code-review-tool-practices-checker.aspx"&gt;Performance Code Review Tool – Practices Checker&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8793251" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item><item><title>Pitfalls With .Net Multithreading And COM Objects – Threads Must Have Compatible Apartment Models (MTA vs. STA)</title><link>http://blogs.msdn.com/alikl/archive/2008/06/20/pitfalls-with-net-multithreading-and-com-objects-threads-must-have-compatible-apartment-models-mta-vs-sta.aspx</link><pubDate>Fri, 20 Jun 2008 10:09:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8624899</guid><dc:creator>alikl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8624899.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8624899</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8624899</wfw:comment><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;Be alert when implementing multithreading .Net in conjunction with COM objects. Thread apartment models matter.&lt;/p&gt;  &lt;p&gt;.Net threads have Multi Threaded Apartment (MTA) model by default. COM objects have Single Thread Apartment (STA). Calling on COM objects on .Net threads that you spawn may cause unpredicted result. &lt;/p&gt;  &lt;p&gt;Multithreading in .Net is easily implemented based on either Thread or ThreadPool objects. Thread.Start() method spawns new thread which has Multi Threaded Apartment (MTA) model . ThreadPool.QueueUserWorkItem(myMethod) queues myMethod to be executed on available thread managed by it.&lt;/p&gt;  &lt;h3&gt;Thread object and COM&lt;/h3&gt;  &lt;p&gt;When spawning your own threads with Thread.Start() set Thread’s apartment model to STA if you plan calling COM object on it:&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; Thread t = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Thread(DoWork);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; t.SetApartmentState(ApartmentState.STA);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; t.Start();&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Note, spawning your own threads with Thread.Start() utilizes resources – mainly CPU, spawning too much threads may cause performance hit. Consider using ThreadPool object.&lt;/p&gt;

&lt;h3&gt;ThreadPool object and COM&lt;/h3&gt;

&lt;p&gt;All threads managed by ThreadPool objects are MTA threads. Apartment model of ThreadPool’s threads cannot be changed. Do not call COM objects on ThreadPool’s threads.&lt;/p&gt;

&lt;h3&gt;Possible designs and solutions&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;ASP.NET.&lt;/strong&gt; Calling COM objects in ASP.NET pages configure &lt;a href="http://msdn.microsoft.com/en-us/library/zwk9h2kb.aspx"&gt;AspCompat=true&lt;/a&gt;: &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Most COM components will work with ASP.NET…”&lt;/p&gt;

  &lt;p&gt;“…The AspCompat attribute forces the page to execute in STA mode. The runtime throws an exception if the compatibility tag is omitted and an STA component is referenced on the page.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Client side (like WinForms)multithreading&lt;/strong&gt;. Use ThreadPool with its MTA threads. Spawn another thread with Thread.Start() setting its apartment model to STA. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Custom server side multithreading&lt;/strong&gt;. I’d consider using Remoting infrastructure. In case your server application should serve messages that are not covered by Remoting’s built in mechanisms I’d consider building my own &lt;a href="http://msdn.microsoft.com/en-us/library/aa309086(VS.71).aspx"&gt;Channel sink&lt;/a&gt;. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;And the last but not the least&lt;/strong&gt;. Do not forget to call Marshal.ReleaseComObject(obj) to dispose the COM objects created on your the threads. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Related materials&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998551.aspx"&gt;Chapter 7 — Improving Interop Performance&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998565.aspx" target="_blank"&gt;Chapter 11 — Improving Remoting Performance&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms979193.aspx" target="_blank"&gt;How To: Improve Serialization Performance&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8624899" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Threading/default.aspx">Threading</category></item><item><title>ASP.NET Performance Engineering - Stress Test Your Architecture, Design, And Code</title><link>http://blogs.msdn.com/alikl/archive/2008/05/05/asp-net-performance-engineering-stress-test-your-architecture-design-and-code.aspx</link><pubDate>Mon, 05 May 2008 13:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8460177</guid><dc:creator>alikl</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8460177.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8460177</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8460177</wfw:comment><description>&lt;p&gt;Field experience proves - the earlier performance is tackled in development lifecycle the better results achieved. Below are most frequent practices that were most helpful in my engagement with the customers.&lt;/p&gt;  &lt;h3&gt;Architecture/Design phase&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;Set performance scope using &lt;a href="http://shapingsoftware.com/2008/03/30/performance-frame" target="_blank"&gt;Performance Frame&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Set performance objectives - &lt;a href="http://blogs.msdn.com/alikl/archive/2007/06/20/performance-testing-objectives-document-template.aspx"&gt;Performance Testing Objectives Document Template&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Generate and distribute performance &lt;a href="http://cid-dd25b83e4ca261f7.skydrive.live.com/self.aspx/Blog%20Bucket/Performance/Performance%20Engineering%20Principles.doc" target="_blank"&gt;engineering principles document&lt;/a&gt; to the dev team (this sample was generated using &lt;a href="http://www.codeplex.com/guidanceExplorer" target="_blank"&gt;Guidance Explorer&lt;/a&gt;) &lt;/li&gt;    &lt;li&gt;Conduct performance design inspection (this &lt;a href="http://cid-dd25b83e4ca261f7.skydrive.live.com/self.aspx/Blog%20Bucket/Performance/Performance%20Design%20Inspection.doc" target="_blank"&gt;sample document&lt;/a&gt; was generated using &lt;a href="http://www.codeplex.com/guidanceExplorer" target="_blank"&gt;Guidance Explorer&lt;/a&gt;) &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Coding phase&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;Conduct static code analysis for performance issues - &lt;a href="http://blogs.msdn.com/alikl/archive/2008/01/21/performance-code-review-tool-practices-checker.aspx" target="_blank"&gt;Performance Code Review Tool &amp;#8211; Practices Checker&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Conduct manual performance code inspection using &lt;a href="http://cid-dd25b83e4ca261f7.skydrive.live.com/self.aspx/Blog%20Bucket/Performance/Performance%20Code%20Inspection.doc" target="_blank"&gt;checklist document&lt;/a&gt; (this sample was generated using &lt;a href="http://www.codeplex.com/guidanceExplorer" target="_blank"&gt;Guidance Explorer&lt;/a&gt;) &lt;/li&gt;    &lt;li&gt;Analyze program's flow early in development - &lt;a href="http://blogs.msdn.com/alikl/archive/2007/07/16/use-sysinternals-debugview-to-diagnose-the-application.aspx" target="_blank"&gt;Use Sysinternals DebugView To Diagnose The Application&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Unit testing phase&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;Conduct performance smoke test for your application - &lt;a href="http://blogs.msdn.com/alikl/archive/2008/03/09/stress-test-asp-net-web-application-with-free-wcat-tool.aspx" target="_blank"&gt;Stress Test ASP.NET Web Application With Free WCAT Tool&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Analyze IIS behavior - &lt;a href="http://blogs.msdn.com/alikl/archive/2007/11/02/identify-asp-net-web-services-and-wcf-performance-issues-by-examining-iis-logs.aspx" target="_blank"&gt;Identify ASP.NET, Web Services, And WCF Performance Issues By Examining IIS Logs&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Analyze Database behavior using SQL Server profiler - &lt;a href="http://msdn.microsoft.com/en-us/library/ms979207.aspx" target="_blank"&gt;How To: Use SQL Profiler&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/ms187929.aspx" target="_blank"&gt;Using SQL Server Profiler&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Analyze Client Side JavaScript behavior -&amp;#160; &lt;a href="http://blogs.msdn.com/alikl/archive/2008/01/17/profiling-javascript-with-ajax-view-tool-spot-poor-performance-client-script-in-no-time.aspx" target="_blank"&gt;Profiling JavaScript With Ajax View Tool: Spot Poor Performance Client Script In No Time&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Analyze ASP.NET behavior - &lt;a href="http://blogs.msdn.com/alikl/archive/2007/08/15/use-performance-counters-templates-to-streamline-performance-analysis.aspx" target="_blank"&gt;Use Performance Counters Templates To Streamline Performance Analysis&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Analyze HTTP traffic from end user's angle - &lt;a href="http://blogs.msdn.com/alikl/archive/2007/10/17/improve-web-application-performance-by-reducing-number-of-http-requests-fiddler-to-the-rescue.aspx" target="_blank"&gt;Improve Web Application Performance By Reducing Number Of Http Requests - Fiddler To The Rescue&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Performance Sins (performance anti-patterns)&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/04/28/performance-sin-chatty-database-access-and-loops-plus-another-free-performance-tool.aspx" target="_blank"&gt;Performance Sin - Chatty Database Access And Loops (Plus Another Free Performance Tool)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/02/02/performance-sin-using-exceptions-to-control-flow.aspx" target="_blank"&gt;Performance Sin - Using Exceptions To Control Flow&lt;/a&gt;&amp;#160; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/05/02/asp-net-performance-sin-serving-images-dynamically-or-another-reason-to-love-fiddler.aspx" target="_blank"&gt;ASP.NET Performance Sin - Serving Images Dynamically (Or Another Reason To Love Fiddler)&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;My related posts&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/ace_team/archive/2008/02/14/do-you-really-need-a-distributed-architecture.aspx"&gt;Do You Really Need A Distributed Architecture?&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/ace_team/archive/2008/03/11/improve-net-applications-performance-effectively-and-efficiently.aspx"&gt;Improve .Net Applications Performance Effectively And Efficiently&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/ace_team/archive/2008/01/15/generate-your-own-security-code-review-checklist-document-using-outlook-2007.aspx"&gt;Generate Your Own Security Code Review Checklist Document Using Outlook 2007&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/01/03/consume-patterns-practices-guidance-explorer-via-rss-using-outlook-2007.aspx"&gt;Consume patterns&amp;amp;practices Guidance Explorer online store via RSS&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/01/08/how-to-keep-asp-net-viewstate-on-the-server-revised.aspx"&gt;How To Keep ASP.NET ViewState On The Server &amp;#8211; Revised&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8460177" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Practices/default.aspx">Practices</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item><item><title>ASP.NET Performance Sin - Serving Images Dynamically (Or Another Reason To Love Fiddler)</title><link>http://blogs.msdn.com/alikl/archive/2008/05/02/asp-net-performance-sin-serving-images-dynamically-or-another-reason-to-love-fiddler.aspx</link><pubDate>Fri, 02 May 2008 16:12:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8450457</guid><dc:creator>alikl</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8450457.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8450457</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8450457</wfw:comment><description>&lt;p&gt;Serving images dynamically may cause performance hit. Dynamically served images require more HTTP requests which violates &lt;a href="http://stevesouders.com/bio.html" target="_blank"&gt;Steve Souders'&lt;/a&gt; performance rule #1 - &lt;a href="http://developer.yahoo.com/performance/rules.html#num_http"&gt;Make Fewer HTTP Requests&lt;/a&gt;. The latency is also caused by parallelism (or parallel downloading) limitations as described in detail here &lt;a href="http://yuiblog.com/blog/2007/04/11/performance-research-part-4/"&gt;Performance Research, Part 4: Maximizing Parallel Downloads in the Carpool Lane&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Static Images&lt;/h3&gt;  &lt;p&gt;Below are the series of images that served dynamically and static.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceSinServingImagesDynamically_BD45/image_11.png" width="157" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;Static images displayed using GridView's ImageFiled column type. ImageField generates the following HTML mark-up:&lt;/p&gt;  &lt;div&gt;   &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;img&lt;/span&gt; &lt;span style="color: #ff0000"&gt;src&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;IMAGES/Birds/icon-penguin.gif&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;style&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;border-width:0px;&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Browser interprets it as a static image and is ready to cache it for further reuse.&lt;/p&gt;

&lt;h3&gt;Serving Images Dynamically&lt;/h3&gt;

&lt;p&gt;Below is the sample code that implements dynamic image serving. I witness in the field different variation but the pattern (I'd call it anti-pattern) remains the same. ASP.NET and HTML mark-up that is usually part of repeater control looks similar to the following:&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;p&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;img&lt;/span&gt; &lt;span style="color: #ff0000"&gt;src&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ServeImage.ashx?FN = &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;%#DataBinder.GetPropertyValue(Container.DataItem, &amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Image&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;quot;)%&amp;gt;&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #0000ff"&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;ASHX file's code that actually serves the image looks similar to this:&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;p&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ProcessRequest(HttpContext context)
{
    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; imageFileName = &lt;/p&gt;&lt;p&gt;           context.Request.MapPath(&lt;span style="color: #006080"&gt;@&amp;quot;IMAGES\&amp;quot; + context.Request.QueryString[&amp;quot;&lt;/span&gt;FN&lt;span style="color: #006080"&gt;&amp;quot;]);

    context.Response.ContentType = &amp;quot;&lt;/span&gt;image/jpeg&amp;quot;;
    context.Response.WriteFile(imageFileName);
    context.Response.Flush();
    context.Response.Close();

}&lt;/p&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3&gt;Network Analysis&lt;/h3&gt;

&lt;p&gt;Using one of my most favorite tools - &lt;a href="http://www.fiddler2.com/fiddler2/" target="_blank"&gt;Fiddler&lt;/a&gt; - it is easy to reveal browser's view on the traffic:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceSinServingImagesDynamically_BD45/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="100" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceSinServingImagesDynamically_BD45/image_thumb_1.png" width="539" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is expiration attribute attached to static images while dynamically served images do not have such attribute. &lt;/p&gt;

&lt;p&gt;Subsequent call the the same page that gets the same images reveals the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceSinServingImagesDynamically_BD45/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="149" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceSinServingImagesDynamically_BD45/image_thumb_3.png" width="538" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All dynamically served images are not cached and utilize the network on each request. &lt;/p&gt;

&lt;p&gt;Further investigation shows, using &lt;a href="http://blogs.msdn.com/alikl/archive/2007/10/17/improve-web-application-performance-by-reducing-number-of-http-requests-fiddler-to-the-rescue.aspx" target="_blank"&gt;Fiddler's P and C fantastic feature&lt;/a&gt;, that overall network utilization caused by these dynamically served images is about 350 KB, which could be saved by caching the images.&lt;/p&gt;

&lt;h3&gt;Recommendations&lt;/h3&gt;

&lt;p&gt;Avoid serving images dynamically. Follow best practices outlined at &lt;a href="http://developer.yahoo.com/performance/" target="_blank"&gt;Exceptional Performance&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#num_http" target="_blank"&gt;Make Fewer HTTP Requests&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#dns_lookups" target="_blank"&gt;Reduce DNS Lookups&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#redirects" target="_blank"&gt;Avoid Redirects&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#cacheajax" target="_blank"&gt;Make Ajax Cacheable&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#postload" target="_blank"&gt;Post-load Components&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#preload" target="_blank"&gt;Preload Components&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#min_dom" target="_blank"&gt;Reduce the Number of DOM Elements&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#split" target="_blank"&gt;Split Components Across Domains&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#iframes" target="_blank"&gt;Minimize the Number of iframes&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://developer.yahoo.com/performance/rules.html#no404" target="_blank"&gt;No 404s&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;My relative posts&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/04/28/performance-sin-chatty-database-access-and-loops-plus-another-free-performance-tool.aspx"&gt;Performance Sin - Chatty Database Access And Loops (Plus Another Free Performance Tool)&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/02/02/performance-sin-using-exceptions-to-control-flow.aspx"&gt;Performance Sin - Using Exceptions To Control Flow&lt;/a&gt;&amp;#160; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8450457" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item><item><title>Securing IIS7 - Windows Server 2008 Security Guide</title><link>http://blogs.msdn.com/alikl/archive/2008/02/28/securing-iis7-windows-server-2008-security-guide.aspx</link><pubDate>Thu, 28 Feb 2008 22:09:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7936911</guid><dc:creator>alikl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/alikl/comments/7936911.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=7936911</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=7936911</wfw:comment><description>&lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/cc264463.aspx" target="_blank"&gt;Windows Server 2008 Security Guide&lt;/a&gt; is out.&lt;/p&gt;  &lt;p&gt;It covers many crucial aspects but my favorite of course is IIS7 chapter:&lt;/p&gt;  &lt;blockquote&gt;   &lt;h4&gt;&lt;a name="_Toc191716753"&gt;Chapter 6: Hardening&lt;/a&gt;&lt;a name="_Idx118"&gt;&lt;/a&gt; Web Services&lt;/h4&gt;    &lt;p&gt;This chapter provides prescriptive guidance for hardening&lt;a name="_Idx119"&gt;&lt;/a&gt; the Web Server role. The chapter discusses how the Web server role installs Microsoft&amp;#174; Internet Information Services&lt;a name="_Idx120"&gt;&lt;/a&gt; (IIS) 7.0, which has been redesigned into forty modular components that you can choose to install as needed.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;It points to the following resources:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://technet2.microsoft.com/WindowsServer2008/en/library/dbaadb7c-433d-4c88-ab7f-1575258131dc1033.mspx" target="_blank"&gt;IIS 7.0: Configuring Authentication in IIS 7.0&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://technet2.microsoft.com/WindowsServer2008/en/library/2464e39e-2a21-4c7b-907c-ed8b4b4f3d031033.mspx" target="_blank"&gt;IIS 7.0: Configuring IPv4 Address and Domain Name Rules&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://technet2.microsoft.com/WindowsServer2008/en/library/ec81dd52-8ddc-41d3-984f-9f710c21add91033.mspx" target="_blank"&gt;IIS 7.0: Configuring URL Authorization Rules in IIS 7.0&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://technet2.microsoft.com/WindowsServer2008/en/library/bf4afb4c-4ce3-40e1-bd4b-d7df6daeb9b61033.mspx" target="_blank"&gt;IIS 7.0: Configuring Server Certificates in IIS 7.0&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://technet2.microsoft.com/WindowsServer2008/en/library/8ddc1f85-27fb-439d-a3da-ced11f7dcf031033.mspx" target="_blank"&gt;IIS 7.0: Configuring ISAPI and CGI Restrictions in IIS 7.0&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://technet2.microsoft.com/WindowsServer2008/en/library/70c33ea8-4192-4110-be70-a11e11984f1e1033.mspx" target="_blank"&gt;IIS 7.0: Configuring Secure Sockets Layer in IIS 7.0&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://technet2.microsoft.com/WindowsServer2008/en/library/7b4d4d2b-780f-47d5-bc6c-514c65754c521033.mspx" target="_blank"&gt;IIS 7.0: Configuring Request Filters&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://technet2.microsoft.com/WindowsServer2008/en/library/b0a91b50-1582-44b5-b61e-7207e6e1c2d11033.mspx" target="_blank"&gt;IIS 7.0: Configuring Shared Configuration&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=103904" target="_blank"&gt;How to Setup SSL on IIS7&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=94165" target="_blank"&gt;How to Use Request Filtering&lt;/a&gt;&lt;a name="_Idx1510"&gt;&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=86769" target="_blank"&gt;Improving Web Application Security: Threats and Countermeasures&lt;/a&gt;&lt;a name="_Idx1511"&gt;&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://technet2.microsoft.com/windowsserver2008/en/library/939d621e-c023-48f8-9503-47f24a6be7211033.mspx?mfr=true" target="_blank"&gt;IIS 7.0: Configure Web Server Security&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=99832" target="_blank"&gt;Server Core Installation Option of Windows Server 2008 Step-By-Step Guide&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=3655" target="_blank"&gt;Windows Management Instrumentation&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=89710" target="_blank"&gt;Windows Server 2008 Technical Library&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=100617" target="_blank"&gt;Understanding IIS7 URL Authorization&lt;/a&gt;.&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7936911" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Deployment+Phase/default.aspx">Deployment Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Deployment+Inspection/default.aspx">Deployment Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/IIS+7/default.aspx">IIS 7</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item><item><title>How To Consume WCF Using AJAX Without ASP.NET</title><link>http://blogs.msdn.com/alikl/archive/2008/02/18/how-to-consume-wcf-using-ajax-without-asp-net.aspx</link><pubDate>Mon, 18 Feb 2008 23:35:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7779790</guid><dc:creator>alikl</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/alikl/comments/7779790.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=7779790</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=7779790</wfw:comment><description>&lt;p&gt;How to consume WCF services directly from Html client? How to add AJAX-like functionally to application that does not natively support ASP.NET AJAX like classic ASP, ASP.NET 1.1, or PHP?&lt;/p&gt;  &lt;p&gt;WCF that ships with .Net 3.5 provides capability to consume it from any JavaScript enabled client via XML or JSON encoding. There is new built in webHttpBinding that supports either JSON or XML encoded messages to be sent to WCF services.The functionality can dramatically improve performance and user experience.&lt;/p&gt;  &lt;p&gt;This post summarizes the steps to create and consume basic WCF service using webHttpBinding binding. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Summary of Steps &lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Step 1 &amp;#8211; Create WCF service.&lt;/b&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Step 2 &amp;#8211; Configure WCF end point.&lt;/b&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Step 3 &amp;#8211; Create JavaScript to invoke WCF service.&lt;/b&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Step 4 &amp;#8211; Test the solution.&lt;/b&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Next section describes each and every step in details&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Step 1 &amp;#8211; Create WCF service&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Open Visual Studio and create new WCF service project by choosing &amp;quot;WCF Service Application&amp;quot; template under &amp;quot;Web&amp;quot; project type. Name it Wcf2Ajax. Open IService1.cs file and create OperationContract as follows:&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; [ServiceContract]&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;  &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; IService1&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;  {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;      [OperationContract]&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;      &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Sum2Integers(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n1, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n2);&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Open Service1.svc.cs file and add public method that accepts to integers and returns the sum of it. This is the functionality that will be exposed by the WCF service and consumed by JavaScript enabled client:&lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Service1 : IService1&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Sum2Integers(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n1, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n2)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; result = num1 + num2;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result.ToString();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;Step 2 &amp;#8211; Configure WCF end point&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Open web.config file and add &amp;lt;binding&amp;gt; section to &amp;lt;system.serviceModel section. Add &amp;lt;webHttpBinding&amp;gt; to binding section:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;bindings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;webHttpBinding&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;binding &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;AjaxBinding&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;webHttpBinding&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;bindings&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Add AjaxBehavior to &amp;lt;behaviors&amp;gt; section to support WCF invocation via AJAX:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;behaviors&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;behavior &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;AjaxBehavior&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;enableWebScript&lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;behavior&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Configure WCF service's endpoint to use newly created binding:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;endpoint &lt;/span&gt;&lt;span style="color: red"&gt;address&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;ajaxEndpoint&lt;/span&gt;&amp;quot; 
          &lt;span style="color: red"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;AjaxBehavior&lt;/span&gt;&amp;quot; 
          &lt;span style="color: red"&gt;binding&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;webHttpBinding&lt;/span&gt;&amp;quot; 
          &lt;span style="color: red"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;AjaxBinding&lt;/span&gt;&amp;quot; 
          &lt;span style="color: red"&gt;contract&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Wcf2Ajax.IService1&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;b&gt;Step 3 &amp;#8211; Create JavaScript to invoke WCF service&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Add Html file to the solution by right clicking on the solution node in solution explorer and choosing &amp;quot;New Item...&amp;quot; and then &amp;quot;HTML Page&amp;quot; template. Name it WCFConsumer.htm. Add few HTML controls - two text boxes to accept two integers, one pure HTML button to trigger WCF call, and &amp;lt;span&amp;gt; element to present the result:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;input &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;num1&amp;quot; /&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;input &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;num2&amp;quot; /&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;br&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;input &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;button&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;onclick&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;CallWcfAjax()&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Call WCF via AJAX&amp;quot; /&amp;gt;
&lt;/span&gt;Result &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;span &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;result&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;span&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Add &amp;lt;script&amp;gt; block to &amp;lt;header&amp;gt; section and add JavaSctip that builds HTTP request and wires invocation function to some event, say button click:&lt;/p&gt;

&lt;pre class="code"&gt;    &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot;&amp;gt;
    function &lt;/span&gt;CallWcfAjax()
    {
        &lt;span style="color: blue"&gt;var &lt;/span&gt;xmlHttp = &lt;span style="color: blue"&gt;new &lt;/span&gt;ActiveXObject(&lt;span style="color: #a31515"&gt;&amp;quot;Microsoft.XmlHttp&amp;quot;&lt;/span&gt;);

        &lt;span style="color: blue"&gt;var &lt;/span&gt;url = &lt;span style="color: #a31515"&gt;&amp;quot;Service1.svc/ajaxEndpoint/&amp;quot;&lt;/span&gt;;
        url = url + &lt;span style="color: #a31515"&gt;&amp;quot;Sum2Integers&amp;quot;&lt;/span&gt;;

        &lt;span style="color: blue"&gt;var &lt;/span&gt;body = &lt;span style="color: #a31515"&gt;'{&amp;quot;n1&amp;quot;:'&lt;/span&gt;;
        body = body + document.getElementById(&lt;span style="color: #a31515"&gt;&amp;quot;num1&amp;quot;&lt;/span&gt;).value + &lt;span style="color: #a31515"&gt;',&amp;quot;n2&amp;quot;:'&lt;/span&gt;;
        body = body + document.getElementById(&lt;span style="color: #a31515"&gt;&amp;quot;num2&amp;quot;&lt;/span&gt;).value + &lt;span style="color: #a31515"&gt;'}'&lt;/span&gt;;
          
        &lt;span style="color: green"&gt;// Send the HTTP request
        &lt;/span&gt;xmlHttp.open(&lt;span style="color: #a31515"&gt;&amp;quot;POST&amp;quot;&lt;/span&gt;, url, &lt;span style="color: blue"&gt;true&lt;/span&gt;);
        xmlHttp.setRequestHeader(&lt;span style="color: #a31515"&gt;&amp;quot;Content-type&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;);
        xmlHttp.send(body);

        &lt;span style="color: green"&gt;// Create result handler 
        &lt;/span&gt;xmlHttp.onreadystatechange= &lt;span style="color: blue"&gt;function &lt;/span&gt;X()
        {
        
             &lt;span style="color: blue"&gt;if&lt;/span&gt;(xmlHttp.readyState == 4)
             {
                  &lt;span style="color: #a31515"&gt;&lt;font color="#333333"&gt;result.innerText&lt;/font&gt;&lt;/span&gt; = xmlHttp.responseText;
             }
        }
    }
    &lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;b&gt;Step 4 &amp;#8211; Test the solution&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Build the solution and navigate to WCFConsumer.htm. Provide two integers to both text boxes and hit &amp;quot;Call WCF via Ajax&amp;quot; button. You should expect for result similar as depicted below:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ConsumeWCFServiceByAnyJavaScriptEnabledC_710F/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="123" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ConsumeWCFServiceByAnyJavaScriptEnabledC_710F/image_thumb.png" width="381" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Parse the result to your needs.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;
&lt;b&gt;My related post&lt;/b&gt;

&lt;p&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/12/31/asp-net-ajax-control-toolkit-basic-sample-for-dynamicpopulate-control.aspx"&gt;ASP.NET AJAX Control Toolkit - Basic Sample For DynamicPopulate Control&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/10/03/ajax-security-client-side-validation-is-for-usability-only-not-for-security.aspx"&gt;AJAX Security - Client Side Validation Is For Usability Only, Not For Security&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/07/26/wcf-security-in-intranet-scenario-thoughts-on-cons-and-pros.aspx"&gt;WCF Security In Intranet Scenario : Thoughts On Cons and Pros&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Related resources&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/bb885100.aspx" target="_blank"&gt;Creating WCF AJAX Services without ASP.NET&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Download Visual Studio 2008 project with the sample from my SkyDrive&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;iframe style="border-right: #dde5e9 1px solid; padding-right: 0px; border-top: #dde5e9 1px solid; padding-left: 0px; padding-bottom: 0px; margin: 3px; border-left: #dde5e9 1px solid; width: 240px; padding-top: 0px; border-bottom: #dde5e9 1px solid; height: 66px; background-color: #ffffff" marginwidth="0" marginheight="0" src="http://cid-dd25b83e4ca261f7.skydrive.live.com/embedrowdetail.aspx/Visual%20Studio%20Projects/Wcf2Ajax.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7779790" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/AJAX/default.aspx">AJAX</category></item><item><title>Design For Operations [DFO] – Problems And Solution Frame</title><link>http://blogs.msdn.com/alikl/archive/2008/01/20/design-for-operations-dfo-problems-and-solution-frame.aspx</link><pubDate>Sun, 20 Jan 2008 20:02:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7173960</guid><dc:creator>alikl</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/alikl/comments/7173960.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=7173960</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=7173960</wfw:comment><description>&lt;p&gt;patterns &amp;amp; practices team maintains &lt;a href="http://www.codeplex.com/dfo"&gt;Design for Operations [DFO] project on codeplex&lt;/a&gt;. The goal of the project focuses on:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#8220;Developing tools and guidance to help enable the development of highly manageable applications on the Windows platform.&amp;#8221; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This post summarize my understanding of the project&amp;#8217;s problems and solutions frame. Most of the content is direct copy paste from more than 300 pages Manageability Guidance document found &lt;a href="http://www.codeplex.com/dfo/Release/ProjectReleases.aspx?ReleaseId=2770" target="_blank"&gt;here&lt;/a&gt; and few interpretations of mine.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4"&gt;Problems Frame&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Active players and their concerns&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;End User&lt;/b&gt;.       &lt;ul&gt;       &lt;li&gt;Why it is not working? &lt;/li&gt;        &lt;li&gt;Why it works so slow? &lt;/li&gt;        &lt;li&gt;Why I am not allowed to do this operation? &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Operator&lt;/b&gt;.       &lt;ul&gt;       &lt;li&gt;How do I configure this? &lt;/li&gt;        &lt;li&gt;Why it failed without alerts? &lt;/li&gt;        &lt;li&gt;Where all alerts are sent? &lt;/li&gt;        &lt;li&gt;How do I roll back the version? &lt;/li&gt;        &lt;li&gt;What should I do when I se this alert? &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Developer&lt;/b&gt;.&lt;b&gt;&lt;/b&gt;       &lt;ul&gt;       &lt;li&gt;How come end users do not understand exception message? &amp;#8211; it is simple call stuck dump! &lt;/li&gt;        &lt;li&gt;What do I do with this &amp;#8220;Unspecified error&amp;#8221; thing? &lt;/li&gt;        &lt;li&gt;What component throws this exception? &lt;/li&gt;        &lt;li&gt;Here is the patch &amp;#8211; just drop it to fix the problem. &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Operations Challenges&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;How do I know what is the source of the incident? For example, &amp;#8220;It is IIS authentication&amp;#8221;. &lt;/li&gt;    &lt;li&gt;How do I get detailed information regarding the incident? For example, &amp;#8220;SPN is not configured for IIS Application account&amp;#8221;. &lt;/li&gt;    &lt;li&gt;How do I recognizes the trends that usually lead to incident? &amp;#8220;Yesterday we had 10% CPU utilization and today it is 20% - it must mean something&amp;#8221;. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4"&gt;Solution Frame&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Representing Applications as Managed Entities&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;A &lt;i&gt;managed entity &lt;/i&gt;is any logical part of an application that a system administrator needs to configure, monitor, and create reports about while managing that application or service. Examples of managed entities are a Web service, a database, an Exchange routing group, an Active Directory site, a computer, a server role, a network device, a hardware component, or a subnet.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/5d7032e04ef4_65E0/clip_image002_2.gif"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="243" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/5d7032e04ef4_65E0/clip_image002_thumb.gif" width="379" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Model Comprehensive Management Models&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Creating a comprehensive management model consists of modeling in a variety of different areas to provide a total system view, including the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Configuration modeling&lt;/b&gt;. This involves encapsulating all the settings that control the behavior or functionality of an application or system component. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Task modeling&lt;/b&gt;. This involves cataloging the complete list of tasks that administrators have to perform to administer and manage a software system or application. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Instrumentation modeling&lt;/b&gt;. This involves capturing the instrumentation used to record the operations of a system or application. Instrumentation provides information to the operations team to increase understanding about how the application functions, and to diagnose problems with an application. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Health modeling&lt;/b&gt;. This involves defining what it means for a system or application to be healthy (operating normally) or unhealthy (operating in a degraded condition or not working at all). A health model represents logically the parts of an application or service the operations team is responsible for keeping operational. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Performance modeling&lt;/b&gt;. This involves capturing the expected baseline performance of an application. Performance counters can then be used to report and expose performance on an ongoing basis, and a monitoring tool can compare this performance to the expected performance. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;Building Effective Health Models&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;An application is considered healthy if it is operating within a series of defined parameters. A number of factors may result in a change in application health, including the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Change in application configuration &lt;/li&gt;    &lt;li&gt;An application update &lt;/li&gt;    &lt;li&gt;A change in an external dependency &lt;/li&gt;    &lt;li&gt;A hardware change &lt;/li&gt;    &lt;li&gt;A network change &lt;/li&gt;    &lt;li&gt;Bad input to the application &lt;/li&gt;    &lt;li&gt;Scalability problems &lt;/li&gt;    &lt;li&gt;Operator error &lt;/li&gt;    &lt;li&gt;Change in deployment &lt;/li&gt;    &lt;li&gt;Malicious attack &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;Steps to handle the problem&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Detect a problem. &lt;/li&gt;    &lt;li&gt;Verify that the problem still exists. &lt;/li&gt;    &lt;li&gt;Diagnose the cause(s) of the problem. &lt;/li&gt;    &lt;li&gt;Resolve the problem. &lt;/li&gt;    &lt;li&gt;Verify that the problem was resolved. &lt;/li&gt;    &lt;li&gt;[My addition] Log the incident and convert it into Knowledge Base gem. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/5d7032e04ef4_65E0/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="167" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/5d7032e04ef4_65E0/image_thumb.png" width="467" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;There are few key terms mentioned above - &amp;quot;Modeling&amp;quot;, &amp;quot;Design&amp;quot;, &amp;quot;Building&amp;quot;, &amp;quot;Maintain&amp;quot;, &amp;quot;Testing&amp;quot;. To me it is absolutely clear that Design For Operations is no different from Security Development Lifecycle or Performance Development Lifecycle. &amp;quot;Operations&amp;quot; is just another important non-functional requirement that needs to be taken throughout the whole development lifecycle to be successfully implemented and deployed in production. It had to be called Operations Development Lifecycle.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;My related posts&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/07/16/use-sysinternals-debugview-to-diagnose-the-application.aspx"&gt;Use Sysinternals DebugView To Diagnose The Application&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/05/02/asp-net-health-monitoring-means-logging-and-auditing.aspx"&gt;ASP.NET Health Monitoring Means Logging And Auditing&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/05/07/security-engineering-big-rocks.aspx"&gt;Security Engineering Big Rocks&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/04/27/threat-modeling-big-chunks.aspx"&gt;Threat Modeling Big Chunks&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/07/04/t-shooting-kerberos.aspx"&gt;T-Shooting Kerberos&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/04/03/who-access-my-file.aspx"&gt;Who Access My File?&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/01/14/chain-of-responsibility-design-pattern-focus-on-security-performance-and-operations.aspx"&gt;Chain Of Responsibility Design Pattern &amp;#8211; Focus On Security, Performance, And Operations&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/11/02/identify-asp-net-web-services-and-wcf-performance-issues-by-examining-iis-logs.aspx"&gt;Identify ASP.NET, Web Services, And WCF Performance Issues By Examining IIS Logs&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/08/15/use-performance-counters-templates-to-streamline-performance-analysis.aspx"&gt;Use Performance Counters Templates To Streamline Performance Analysis&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7173960" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Practices/default.aspx">Practices</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Operations/default.aspx">Operations</category></item><item><title>Chain Of Responsibility Design Pattern – Focus On Security, Performance, And Operations</title><link>http://blogs.msdn.com/alikl/archive/2008/01/14/chain-of-responsibility-design-pattern-focus-on-security-performance-and-operations.aspx</link><pubDate>Mon, 14 Jan 2008 18:50:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7108994</guid><dc:creator>alikl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/alikl/comments/7108994.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=7108994</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=7108994</wfw:comment><description>&lt;p&gt;The pattern is also called Intercepting Filter, Pipeline, AOP, and may be few more&amp;#8230; I am confused by the name for this design pattern. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://thinkexist.com/quotation/life_is_really_simple-but_we_insist_on_making_it/201092.html" target="_blank"&gt;&amp;#8220;Life is really simple, but we insist on making it complicated.&amp;#8221;&lt;/a&gt; - Confucius &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;No matter how they call it I like the idea of decoupling actions while processing one after another. Here is the definition from &lt;a href="http://www.dofactory.com/Patterns/PatternChain.aspx" target="_blank"&gt;data &amp;amp; object factory&lt;/a&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Intercepting Filter visual from MSDN&amp;#8217;s &lt;a href="http://msdn.microsoft.com/msdnmag/issues/05/07/DesignPatterns/#S10" target="_blank"&gt;Discover the Design Patterns You're Already Using in the .NET Framework&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ChainOfResponsibilityDesignPatternFocusO_DFF4/clip_image005_2.gif"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="82" alt="clip_image005" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ChainOfResponsibilityDesignPatternFocusO_DFF4/clip_image005_thumb.gif" width="233" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;.Net framework implements Chain Of Responsibility design pattern for many its internal mechanisms. My favorite is HttpModule. I like it so much I decided to build my own pipeline.&lt;/p&gt;  &lt;p&gt;This post summarizes my steps I took to create my own simple implementation for this design pattern. I did not do any research purposely online and wanted to get my hands dirty without bias.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;The goal&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;My goal was creating simple code that can be adopted and extended:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The code should be very simple &lt;/li&gt;    &lt;li&gt;The code should provide pipeline infrastructure to invoke aspects/filters &lt;/li&gt;    &lt;li&gt;The code should allow dynamic invocation of any arbitrary number of aspects &lt;/li&gt;    &lt;li&gt;The code should include no optimization to stay simple &lt;/li&gt;    &lt;li&gt;The code should demonstrate practical idea and not be state of the art, production ready to go one. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;What I needed&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Provide generic mechanism that will execute arbitrary logic &amp;#8211; the Pipeline. &lt;/li&gt;    &lt;li&gt;The logic is encapsulated in decoupled components &amp;#8211; Aspects. &lt;/li&gt;    &lt;li&gt;Aspects can be independently configured without rebuilding the application. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;The design&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ChainOfResponsibilityDesignPatternFocusO_DFF4/clip_image006_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="227" alt="clip_image006" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ChainOfResponsibilityDesignPatternFocusO_DFF4/clip_image006_thumb.png" width="423" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Summary of steps&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Step #1 &amp;#8211; Create base classes and interfaces.&lt;/b&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Step #2 &amp;#8211; Create concrete implementation of specific Pipeline.&lt;/b&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Step #3 &amp;#8211; Modify config file.&lt;/b&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Step #4 &amp;#8211; Test the solution.&lt;/b&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Following section describes each step in details&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Step #1 &amp;#8211; Create base classes and interfaces.&lt;/b&gt; I needed two bases classes - BasePipeline and IAspect. BasePipeline is responsible to perform generic actions of:       &lt;ul&gt;       &lt;li&gt;Consulting configuration file. &lt;/li&gt;        &lt;li&gt;Loading the configured aspects. &lt;/li&gt;        &lt;li&gt;And invoking them one by one. &lt;/li&gt;     &lt;/ul&gt;      &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;LoadPipelineAspects()
{
    aspects = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;IAspect&lt;/span&gt;&amp;gt;();

    &lt;span style="color: #2b91af"&gt;Configuration &lt;/span&gt;config = &lt;/pre&gt;

    &lt;pre class="code"&gt;                  &lt;span style="color: #2b91af"&gt;ConfigurationManager&lt;/span&gt;.OpenExeConfiguration(&lt;/pre&gt;

    &lt;pre class="code"&gt;                  &lt;span style="color: #2b91af"&gt;ConfigurationUserLevel&lt;/span&gt;.None);

    &lt;span style="color: blue"&gt;string  &lt;/span&gt;piplineConfig = &lt;/pre&gt;

    &lt;pre class="code"&gt;            config.AppSettings.Settings[pipelineName].Value;

    &lt;span style="color: blue"&gt;string&lt;/span&gt;[] aspectNames = piplineConfig.Split(&lt;span style="color: #a31515"&gt;','&lt;/span&gt;);

    &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;i = 0; i &amp;lt; aspectNames.Length; i++)
    {

        &lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;t = &lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;.GetType(aspectNames[i]);

        &lt;span style="color: #2b91af"&gt;IAspect &lt;/span&gt;aspect=(&lt;span style="color: #2b91af"&gt;IAspect&lt;/span&gt;)&lt;span style="color: #2b91af"&gt;Activator&lt;/span&gt;.CreateInstance(t);

        aspects.Add(aspect);

    }
}&lt;/pre&gt;
IAspect interface serves as a contract between BasePipline and aspect's concrete implementation. Take a look at the design diagram. When the client invokes HandleRequest method on concrete Pipeline implementation it invokes underneath generic implementation of the method of its base - BasePipeline: 

    &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public virtual bool &lt;/span&gt;HandleRequest(&lt;span style="color: blue"&gt;object &lt;/span&gt;request) 
{

    &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;IAspect &lt;/span&gt;item &lt;span style="color: blue"&gt;in &lt;/span&gt;aspects)
    {
        item.ProcessRequest(request);
    }
    &lt;span style="color: blue"&gt;return true&lt;/span&gt;;
}&lt;/pre&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;b&gt;Step #2 &amp;#8211; Create concrete implementations.&lt;/b&gt; Concrete implementations of both types SimplePipeline and SimpleAspect are nothing fancy. SimplePipeline calls into its base but reserves the right to add any additions without interfering with any other concrete implementations: 

    &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public override bool &lt;/span&gt;HandleRequest(&lt;span style="color: blue"&gt;object &lt;/span&gt;request)
{
    &lt;span style="color: blue"&gt;base&lt;/span&gt;.HandleRequest(request);

    &lt;span style="color: blue"&gt;return true&lt;/span&gt;;
} &lt;/pre&gt;
To indicate what aspect is running I simply spit out aspect's name for aspect's ProcessRequest. That is the place where the whole logic should be performed - DB access, Web Services calls, request modifications etc : 

    &lt;br /&gt;

    &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public bool &lt;/span&gt;ProcessRequest(&lt;span style="color: blue"&gt;object &lt;/span&gt;request)
{
    &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;processing from SimpleAspect1&amp;quot;&lt;/span&gt;);
    &lt;span style="color: blue"&gt;return true&lt;/span&gt;;
}&lt;/pre&gt;
    &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;b&gt;Step #3 &amp;#8211; Modify config file.&lt;/b&gt; Config file - app.config or web.config in my case - holds the information about what aspects should be called for specific pipeline: 

    &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;appSettings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;key &lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;br /&gt;&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;MyPipeline.SimplePipeline&lt;/span&gt;&amp;quot; 
 &lt;span style="color: red"&gt;value &lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;MyPipeline.SimpleAspect1,MyPipeline.SimpleAspect2&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;appSettings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

    &lt;p&gt;The &lt;span style="color: red"&gt;key &lt;/span&gt;is the type of the pipeline and the &lt;span style="color: red"&gt;value &lt;/span&gt;is comma separated types of the aspects. When the concrete pipeline is instantiated by the client it already knows it type which serves to consult the config file and identify what aspects to load using reflection. This is how BasePipeline constructor looks like:&lt;/p&gt;

    &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public &lt;/span&gt;BasePipeline()
{
    pipelineName = &lt;span style="color: blue"&gt;this&lt;/span&gt;.ToString();
    
    LoadPipelineAspects();

}&lt;/pre&gt;
    &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

    &lt;p&gt;See &lt;strong&gt;Step #1&lt;/strong&gt; for LoadPipelineAspects() function implementation where reflection magic happens to dynamically load the aspects.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;b&gt;Step #4 &amp;#8211; Test the solution.&lt;/b&gt; To test the solution follow these steps: 

    &lt;ul&gt;
      &lt;li&gt;Create Class library project and reference to the library where Pipeline base classes reside. Implement your own Pipeline while inheriting from BasePipeline. &lt;/li&gt;

      &lt;li&gt;Implement few aspects that implement IAspect interface. &lt;/li&gt;

      &lt;li&gt;Create simple Windows Console application, add reference to the libraries and add simple code similar to this to Main function: 
        &lt;pre class="code"&gt;MyPipeline.&lt;span style="color: #2b91af"&gt;SimplePipeline &lt;/span&gt;sp = &lt;br /&gt;&lt;span style="color: blue"&gt;                        new &lt;/span&gt;MyPipeline.&lt;span style="color: #2b91af"&gt;SimplePipeline&lt;/span&gt;();

sp.HandleRequest(&lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;/pre&gt;
      &lt;/li&gt;

      &lt;li&gt;
        &lt;p&gt;In the config file add modifications as described in &lt;strong&gt;Step #3.&lt;/strong&gt;&lt;/p&gt;
      &lt;/li&gt;

      &lt;li&gt;
        &lt;p&gt;Run the application.&lt;/p&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Done. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ChainOfResponsibilityDesignPatternFocusO_DFF4/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="123" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ChainOfResponsibilityDesignPatternFocusO_DFF4/image_thumb.png" width="307" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Any time one needs to change the logic, add/remove aspects - it is just a matter of tweaking config file - that is it. &lt;/p&gt;

&lt;p&gt;I've just copied and pasted existing aspects inside the configuration file and run the application again, here is what I get:&lt;/p&gt;

&lt;p&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;key &lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;MyPipeline.SimplePipeline&lt;/span&gt;&amp;quot; 

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: red"&gt;value &lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;MyPipeline.SimpleAspect1, 
    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyPipeline.SimpleAspect2, 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyPipeline.SimpleAspect1, 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyPipeline.SimpleAspect2, 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyPipeline.SimpleAspect1, 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyPipeline.SimpleAspect2&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;/&amp;gt; 
    &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ChainOfResponsibilityDesignPatternFocusO_DFF4/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="126" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ChainOfResponsibilityDesignPatternFocusO_DFF4/image_thumb_1.png" width="272" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I think it is cool.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Focus on Security&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;From security perspective there are few things to keep in mind. When invoking assemblies with reflection there is immediate risk of luring attacks that result in spoofed assemblies. For more information how to get protected see my related post below - &lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/12/net-assembly-spoof-attack.aspx"&gt;.Net Assembly Spoof Attack&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Focus on Performance&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Reflection is considered as slow operation. Everything is relative. In case where reflection is used in performance critical application you should consider performance optimization for reflection. One such optimization is constructor caching as described in &lt;a href="http://weblogs.asp.net/bradygaster/archive/2003/11/26/39952.aspx" target="_blank"&gt;More Provider Goodieness&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Focus on Operations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From operations perspective it seems ideal case. I witnessed few times the situation where the change was not an option since it required whole rebuild of the application - something that operations team was not happy with and put veto on it.&lt;/p&gt;

&lt;p&gt;The trick is constantly asking yourself &amp;quot;What I am optimizing? Security, Performance, or Operations?&amp;quot;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My related posts&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/12/net-assembly-spoof-attack.aspx"&gt;.Net Assembly Spoof Attack&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/12/26/basic-httpmodule-sample-plus-bonus-case-study-how-httomodule-saved-mission-critical-project-s-life.aspx"&gt;Basic HttpModule Sample (Plus Bonus Case Study - How HttpModule Saved Mission Critical Project's Life)&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/04/how-to-hack-wcf-new-technology-old-hacking-tricks.aspx"&gt;How To Hack WCF - New Technology, Old Hacking Tricks&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/05/18/aop-pipelines-interceptors-and-httpmodlues.aspx"&gt;AOP, Pipelines, Interceptors, and HttpModlues&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/10/06/iis-7-great-finds-how-to-setup-iis7-on-vista-bulk-web-site-creation-asp-net-pipeline-integration-with-iis7.aspx"&gt;IIS 7 Great Finds - How To Setup IIS7 On Vista, Bulk Web Site Creation, ASP.NET Pipeline Integration With IIS7&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://cid-dd25b83e4ca261f7.skydrive.live.com/self.aspx/Visual%20Studio%20Projects/Alikl.BasicSamples.zip" target="_blank"&gt;Download the sample from my SkyDrive&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe style="border-right: #dde5e9 1px solid; padding-right: 0px; border-top: #dde5e9 1px solid; padding-left: 0px; padding-bottom: 0px; margin: 3px; border-left: #dde5e9 1px solid; width: 240px; padding-top: 0px; border-bottom: #dde5e9 1px solid; height: 66px; background-color: #ffffff" marginwidth="0" marginheight="0" src="http://cid-dd25b83e4ca261f7.skydrive.live.com/embedrowdetail.aspx/Visual%20Studio%20Projects/Alikl.BasicSamples.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;

&lt;p&gt;Have fun.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7108994" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item><item><title>ASP.NET AJAX Control Toolkit - Basic Sample For DynamicPopulate Control</title><link>http://blogs.msdn.com/alikl/archive/2007/12/31/asp-net-ajax-control-toolkit-basic-sample-for-dynamicpopulate-control.aspx</link><pubDate>Mon, 31 Dec 2007 07:49:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6912858</guid><dc:creator>alikl</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/alikl/comments/6912858.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=6912858</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=6912858</wfw:comment><description>&lt;p&gt;How to dynamically populate the content of a control based on Web Service call triggered by another control? &lt;a href="http://asp.net/AJAX/AjaxControlToolkit/Samples/DynamicPopulate/DynamicPopulate.aspx" target="_blank"&gt;DynamicPopulate extender&lt;/a&gt; to the rescue:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;DynamicPopulate is a simple extender that replaces the contents of a control with the result of a web service or page method call. The method call returns a string of HTML that is inserted as the children of the target element.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This post to summarize basic steps of using AJAX Control Toolkit's DynamicPopulate extender. Plus customer's case study of how it was implemented with ASP.NET Masterpage for performance and UX improvement.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Summary of steps&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Step 1 - Create ASP.NET Web Application&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Step 2 - Add server side code&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Step 3 - Add DynamicPopulate extender&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Step 4 - Add client side script to use the extender behavior&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Step 5 - Add client side event to invoke the client script&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Step 6 - Test the solution&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Following section describes each step in details.&lt;/p&gt;  &lt;div class="pullquote_right"&gt;&lt;b&gt;&amp;quot;Then another ask came through - content page must update the sidebar that is part of the Master page....&amp;quot;&lt;/b&gt;&lt;/div&gt;  &lt;li&gt;&lt;strong&gt;Step 1 - Create ASP.NET Web Application. &lt;/strong&gt;Open &lt;a href="http://www.microsoft.com/visualstudio" target="_blank"&gt;Visual Studio 2008&lt;/a&gt;. Create new &amp;quot;ASP.NET Web Application&amp;quot; project, found under Web node in &amp;quot;New Project&amp;quot; dialog. Name it DynamicPopulateSample. Add site's Master Page by right clicking on the project in project explorer window, then &amp;quot;Add&amp;quot; -&amp;gt;&amp;#160; &amp;quot;New Item...&amp;quot;, then choose &amp;quot;Master Page&amp;quot; template from the &amp;quot;New Item&amp;quot; dialog. Leave its default name. Drag Label control on the Master page from the Tool Box. The Label will be dynamically updated. Add new ASPX page by right clicking on the project in project explorer window, then &amp;quot;Add&amp;quot; -&amp;gt; &amp;quot;New Item....&amp;quot;, then choose &amp;quot;Web Content Form&amp;quot;. Specify it's Master Page by choosing Site1.Master. Name it default.aspx. Add two pure Html radio buttons to default.aspx. These will serve as a trigger to update the Label on the Master Page. Add &lt;a href="http://asp.net/AJAX/AjaxControlToolkit/Samples/Default.aspx" target="_blank"&gt;AjaxControlToolkit.dll&lt;/a&gt; to the project's&amp;#160; bin folder and add reference to it. &lt;/li&gt;  &lt;li&gt;&lt;strong&gt;Step 2 - Add server side code.&lt;/strong&gt; Open default.aspx.cs code behind for default.aspx. Add the following function:     &lt;pre class="code"&gt;[System.Web.Services.&lt;span style="color: #2b91af"&gt;WebMethod&lt;/span&gt;]
[System.Web.Script.Services.&lt;span style="color: #2b91af"&gt;ScriptMethod&lt;/span&gt;]
&lt;span style="color: blue"&gt;public static string &lt;/span&gt;GetHtml(&lt;span style="color: blue"&gt;string &lt;/span&gt;contextKey)
{
    &lt;span style="color: green"&gt;// A little pause to mimic a latent call
    // This is the place to perform server side
    // code like DB access
    &lt;/span&gt;System.Threading.&lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;.Sleep(350);

    &lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;span style="color: #2b91af"&gt;String&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;&amp;quot;Persona: {0}&amp;quot;&lt;/span&gt;, contextKey);
}&lt;/pre&gt;
&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;Step 3 - Add DynamicPopulate extender.&lt;/strong&gt; Register AjaxControlToolkit assembly inside the page. Add the following declaration right after &amp;lt;@Page...&amp;gt; directive&amp;#160; &lt;br /&gt;&lt;span style="background: #ffee62"&gt;&lt;/span&gt;

  &lt;p&gt;&lt;span style="background: #ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: blue"&gt;@ &lt;/span&gt;&lt;span style="color: #a31515"&gt;Register 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: red"&gt;Assembly&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;AjaxControlToolkit&amp;quot; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: red"&gt;Namespace&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;AjaxControlToolkit&amp;quot; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: red"&gt;TagPrefix&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ajaxToolkit&amp;quot;&lt;/span&gt;&lt;span style="background: #ffee62"&gt;%&amp;gt; 
      &lt;br /&gt;&lt;/span&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

    &lt;br /&gt;Add AJAX Script Manager to the page:&amp;#160; &lt;br /&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;ScriptManager &lt;/span&gt;&lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ScriptManager1&amp;quot;&lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;server&amp;quot;/&amp;gt;&lt;/span&gt; &lt;/p&gt;

  &lt;p&gt;Add DynamicPopulateExtender control to the page:&lt;/p&gt;

  &lt;p&gt;&amp;#160; &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ajaxToolkit&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DynamicPopulateExtender 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;dp&amp;quot;&lt;/span&gt;&lt;span style="color: red"&gt;BehaviorID&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;dp1&amp;quot;&lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;server&amp;quot; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: red"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;form1$Label1&amp;quot; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: red"&gt;ClearContentsDuringUpdate&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;true&amp;quot; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: red"&gt;ServiceMethod&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;GetHtml&amp;quot; /&amp;gt; &lt;/span&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;

  &lt;p&gt;Notice TargetControlID is set to &amp;quot;&lt;font color="#0000ff"&gt;form1$Label1&lt;/font&gt;&amp;quot;. This is the Label control to be updated with the Html string returned by the server side code I described in Step 2. $ notation means nesting - read &amp;quot;Label1 control inside form1 control&amp;quot;. It can be any nesting depth. Save your work and then view in browser to make sure that no exceptions generated. &lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;Step 4 - Add client side script to use the extender behavior.&lt;/strong&gt;&amp;#160; So far, there is Label1 to be updated and it is sitting in the Mater page. There is DynamicPopulateExtender that defines the behavior. There is server side code to handle the request. Now add client script that makes the request to the server: 

  &lt;br /&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;

  &lt;p&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot;&amp;gt; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; function &lt;/span&gt;updateDateKey(value) { 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;var &lt;/span&gt;behavior = $find(&lt;span style="color: #a31515"&gt;'dp1'&lt;/span&gt;); 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt;(behavior) { 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; behavior.populate(value); 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Sys.Application.add_load(&lt;span style="color: blue"&gt;function&lt;/span&gt;(){updateDateKey(&lt;span style="color: #a31515"&gt;'Alik Levin'&lt;/span&gt;);}); 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
  &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

  &lt;p&gt;Notice initialization function call - the last row. It invokes the client side function to call into server side for the first time when the page is rendered into the browser for the first time. &lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;Step 5 - Add client side event to invoke the client script.&lt;/strong&gt; The last part is adding the event that triggers the client side code to be invoked and thus making call to the server. Locate Html radio buttons that were created during Step 1, add onclick events to call the client side function: 

  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;input &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;radio&amp;quot; 
       &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;rbFormat&amp;quot; 
       &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;r0&amp;quot; 
       &lt;/span&gt;&lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;='alik'
       &lt;/span&gt;&lt;span style="color: red"&gt;onclick&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;updateDateKey(this.value);&amp;quot; 
       &lt;/span&gt;&lt;span style="color: red"&gt;checked&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;checked&amp;quot; /&amp;gt;&lt;/span&gt;click to set 'alik'&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;br&lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;input &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;radio&amp;quot; 
       &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;rbFormat&amp;quot; 
       &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Radio1&amp;quot; 
       &lt;/span&gt;&lt;span style="color: red"&gt;onclick&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;updateDateKey(this.value);&amp;quot;
       &lt;/span&gt;&lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;='levin' /&amp;gt;&lt;/span&gt;click to set 'levin'&lt;/pre&gt;
  &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;Step 6 - Test the solution.&lt;/strong&gt; Save your work and view in browser. Click on the radio buttons and you should see how the Label in master page gets updated with respective values. It all happens with small delays simulated on the server by Sleep function. I think it is cool. 

  &lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;Case Study&lt;/strong&gt; &lt;/li&gt;
  &lt;/ul&gt;

  &lt;p&gt;I was asked by a customer to offer a solution for very responsive UX [User Experience] while avoiding annoying refresh of the web page. Natural answer was AJAX. The customer also asked to provide the solution for common look and feel. Master pages was my answer. Then another ask came through - content page must update the sidebar that is part of the Master page.... hmm A-ha! Use DynamicPopulateExtender.&lt;/p&gt;

  &lt;p&gt;&lt;strong&gt;My Related posts&lt;/strong&gt;&lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;
      &lt;p&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/10/03/ajax-security-client-side-validation-is-for-usability-only-not-for-security.aspx" target="_blank"&gt;AJAX Security - Client Side Validation Is For Usability Only, Not For Security&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;

    &lt;li&gt;
      &lt;p&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/12/18/asp-net-3-5-extensions-basic-steps-to-create-dynamic-data-web-application-focus-on-security-and-performance.aspx" target="_blank"&gt;ASP.NET 3.5 Extensions: Basic Steps To Create Dynamic Data Web Application - Focus On Security and Performance&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ul&gt;

  &lt;p&gt;Sample VS2008 project that demonstrates DynamicPopulateExtender can be found on my SkyDrive:&lt;/p&gt;

  &lt;p&gt;&amp;#160;&lt;iframe style="border-right: #dde5e9 1px solid; padding-right: 0px; border-top: #dde5e9 1px solid; padding-left: 0px; padding-bottom: 0px; margin: 3px; border-left: #dde5e9 1px solid; width: 240px; padding-top: 0px; border-bottom: #dde5e9 1px solid; height: 66px; background-color: #ffffff" marginwidth="0" marginheight="0" src="http://cid-dd25b83e4ca261f7.skydrive.live.com/embedrowdetail.aspx/Visual%20Studio%20Projects/DynamicPopulateSample.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;

  &lt;p&gt;Watch UX [User Experience] in the video below: &lt;/p&gt;
  &lt;embed pluginspage="http://macromedia.com/go/getflashplayer" src="http://images.video.msn.com/flash/soapbox1_1.swf" width="432" height="364" type="application/x-shockwave-flash" quality="high" base="http://images.video.msn.com" allowfullscreen="true" flashvars="c=v&amp;amp;v=e5437b52-24c0-4d3d-8189-17d5085d96d9&amp;amp;ifs=true&amp;amp;fr=msnvideo&amp;amp;mkt=en-US&amp;amp;brand=" /&gt; 

  &lt;br /&gt;&lt;a title="DynamicPopulateExtender Demo" href="http://video.msn.com/video.aspx?vid=e5437b52-24c0-4d3d-8189-17d5085d96d9" target="_new"&gt;Video: DynamicPopulateExtender Demo&lt;/a&gt; 

  &lt;p&gt;Enjoy.&lt;/p&gt;
&lt;/li&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6912858" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/AJAX/default.aspx">AJAX</category></item><item><title>ASP.NET 3.5 Extensions: Basic Steps To Create Dynamic Data Web Application - Focus On Security and Performance</title><link>http://blogs.msdn.com/alikl/archive/2007/12/18/asp-net-3-5-extensions-basic-steps-to-create-dynamic-data-web-application-focus-on-security-and-performance.aspx</link><pubDate>Tue, 18 Dec 2007 13:08:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6795451</guid><dc:creator>alikl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/alikl/comments/6795451.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=6795451</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=6795451</wfw:comment><description>&lt;p&gt;This post walks through the steps I've taken to create simple Dynamic Data Web Application. I just loved the development model for &lt;a href="http://msdn2.microsoft.com/en-us/library/ms978717.aspx" target="_blank"&gt;DTO [Data Transfer Object]&lt;/a&gt; and Input Validation options.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Summary of steps&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Step 1 - Download and install ASP.NET Extensions.&lt;/strong&gt;  &lt;li&gt;&lt;strong&gt;Step 2 - Create New Dynamic Data Web Application in VS2008&lt;/strong&gt;  &lt;li&gt;&lt;strong&gt;Step 3 - Add "LINQ to SQL Classes" file to the project&lt;/strong&gt;  &lt;li&gt;&lt;strong&gt;Step 4 - Test the project&lt;/strong&gt;  &lt;li&gt;&lt;strong&gt;Step 5 - Create Model Class and add validation rules&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Following are detailed explanations for each step.&lt;/p&gt; &lt;li&gt;&lt;strong&gt;Step 1 - Download and install ASP.NET Extensions. &lt;/strong&gt;ASP.NET Extensions can be found here - &lt;a title="http://asp.net/downloads/3.5-extensions/" href="http://asp.net/downloads/3.5-extensions/" target="_blank"&gt;http://asp.net/downloads/3.5-extensions/&lt;/a&gt;. I installed it on my Vista machine that has Visual Studio 2008 installed.  &lt;li&gt;&lt;strong&gt;Step 2 - Create New Dynamic Data Web Application in VS2008.&lt;/strong&gt; Open Visual Studio 2008 and choose "Dynamic Data Web Application" template found under Web node. Make sure that the project references System.Web.Extensions assembly version 3.6. If not then remove it and reference the assembly from "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\ASP.NET 3.5 Extensions\System.Web.Extensions.dll".  &lt;li&gt;&lt;strong&gt;Step 3 - Add "LINQ to SQL Classes" file to the project. &lt;/strong&gt;Right click on the project and choose "Add"-&amp;gt;"New Item..." and then choose "LINQ to SQL Classes" template from "Data" node. In server Explorer expand "Data Connections" node, expand desired database, and then expand "Tables" node. Highlight desired tables and then drag them onto "LINQ to SQL Classes" component [double click file with .dbml extension].  &lt;li&gt;&lt;strong&gt;Step 4 - Test the project.&lt;/strong&gt; Right click on default.aspx page and choose "View in Browser". The page should look similar to the picture below. Click on the tables names to see the actual values and master-child view.  &lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/BasicStepsToCreateDynamicDataWebApplicat_13F6F/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 10px 20px; border-right-width: 0px" height="211" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/BasicStepsToCreateDynamicDataWebApplicat_13F6F/image_thumb.png" width="234" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;li&gt;&lt;strong&gt;Step 5 - Create Model Class and add validation rules. &lt;/strong&gt;Adding validation rules can be accomplished using .Net attributes declaratively or using partial methods. Create new class. Add "&lt;font color="#0000ff"&gt;using&lt;/font&gt; System.Web.DynamicData;" declaration. Delete the default constructor. Add partial class with the name of desired table, say "Item" or/and&amp;nbsp; "Product".  &lt;ul&gt; &lt;ul&gt; &lt;li&gt;&lt;em&gt;&lt;u&gt;Attribute based input validation&lt;/u&gt;&lt;/em&gt;. Add attribute to the class, for example to check range for ListPrice field/column and add the following declaration:&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/BasicStepsToCreateDynamicDataWebApplicat_13F6F/image_6.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="65" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/BasicStepsToCreateDynamicDataWebApplicat_13F6F/image_thumb_2.png" width="401" border="0"&gt;&lt;/a&gt;  &lt;li&gt;&lt;u&gt;&lt;em&gt;Partial method input validation&lt;/em&gt;&lt;/u&gt;. Add partial method for desired field change [intelliSense really rocks at this part] and then add validation logic:&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/BasicStepsToCreateDynamicDataWebApplicat_13F6F/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="104" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/BasicStepsToCreateDynamicDataWebApplicat_13F6F/image_thumb_3.png" width="400" border="0"&gt;&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt; &lt;p&gt;Validation rules propagated to both client [for usability] and server [for security], this is how violation of input validation looks in it default view:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/BasicStepsToCreateDynamicDataWebApplicat_13F6F/image_10.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="60" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/BasicStepsToCreateDynamicDataWebApplicat_13F6F/image_thumb_4.png" width="410" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Heaven. &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Focus on Security&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;I can create data driven web pages using GridView and DataSets. The drawback is that validation is not that straightforward. On other hand I can create custom collections and manually data bind it - the code is much nicer and cleaner and validation rules are easy to add but there is the need of writing extra code. In the case of Dynamic Data there is fantastic combination of design time productivity and also clean code where validation rules are applied directly to the &lt;em&gt;model&lt;/em&gt;. Less room for mistake to introduce security vulnerability.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Focus on Performance&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Ready to go templates that are generated with the default Dynamic Data projects already implement AJAX and paging. It reduces dramatically amount of data that round trips over the wire. Large HTML output - including ViewState - is one of the biggest performance vulnerabilities I've noticed recently. AJAX and paging is a great way to overcome this issue.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;My related posts&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/10/03/ajax-security-client-side-validation-is-for-usability-only-not-for-security.aspx"&gt;AJAX Security - Client Side Validation Is For Usability Only, Not For Security&lt;/a&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/07/06/typed-dataset-potential-performance-and-security-risk.aspx"&gt;Typed DataSet - Potential Performance And Security Risk&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;ul&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Related materials&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The post was inspired and based on &lt;a href="http://blogs.msdn.com/davidebb/archive/2007/12/12/dynamic-data-screencast-is-now-available.aspx" target="_blank"&gt;David Ebbo's fantastic screencast&lt;/a&gt;  &lt;li&gt;&lt;a title="http://quickstarts.asp.net/3-5-extensions/" href="http://quickstarts.asp.net/3-5-extensions/" target="_blank"&gt;ASP.NET 3.5 Extensions Quickstarts&lt;/a&gt;  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/msdnmag/issues/03/02/CuttingEdge/#S6" target="_blank"&gt;Keeping View State on the Server&lt;/a&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/jmeier/archive/2007/08/28/performance-threats.aspx" target="_blank"&gt;Performance Threats&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6795451" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/AJAX/default.aspx">AJAX</category></item><item><title>Avoid Manipulating Passwords In Memory - It Is Easy To Reveal</title><link>http://blogs.msdn.com/alikl/archive/2007/12/08/avoid-manipulating-passwords-in-memory-it-is-easy-to-reveal.aspx</link><pubDate>Sat, 08 Dec 2007 08:55:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6701111</guid><dc:creator>alikl</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/alikl/comments/6701111.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=6701111</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=6701111</wfw:comment><description>&lt;p&gt;Revealing clear text passwords in memory seems to be a trivial task. This post describes how to reveal clear text passwords and what countermeasures to apply.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Summary of steps:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Install WinDbg&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Attach to process or open dump file&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Load SOS .Net extensions for WinDbg&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Enumerate threads&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Enumerate objects in thread&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Dump object's values&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Countermeasures and guidelines&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Install WinDbg&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Download and install WinDbg as described in &lt;a href="http://blogs.msdn.com/johan/archive/2007/01/11/how-to-install-windbg-and-get-your-first-memory-dump.aspx"&gt;How to install Windbg and get your first memory dump&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Attach to process or open dump file&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;WinDbg can analyze both running processes and memory dumps which conveniently can be taken offsite for further investigation. I've created simple console application that accepts user name and password pair as its parameters and stores in local variables in memory:&lt;/p&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;static void&lt;/font&gt; Main(&lt;font color="#0000ff"&gt;string&lt;/font&gt;[] args)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;string&lt;/font&gt; userName = Console.ReadLine();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;string&lt;/font&gt; password = Console.ReadLine();  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.ReadLine();&lt;br&gt;} &lt;p&gt;Compile and run the application. I called it SecretsInMemory. This is how it looks when running: &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_12.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="89" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_thumb_5.png" width="284" border="0"&gt;&lt;/a&gt;  &lt;p&gt;Attach WinDbg to the running application by opening File-&amp;gt;Attach to a Process: &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="89" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_thumb.png" width="390" border="0"&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp; &lt;p&gt;and press Ok. &lt;p&gt;Alternatively, we can create dump file - for detailed how-to refer to &lt;a href="http://blogs.msdn.com/johan/archive/2007/01/11/how-to-install-windbg-and-get-your-first-memory-dump.aspx" target="_blank"&gt;How to install Windbg and get your first memory dump&lt;/a&gt;. &lt;p&gt;To Investigate resulting dump file in WinDbg open File-&amp;gt;Open Crash Dump &lt;p&gt;&lt;strong&gt;Load SOS .Net extensions for WinDbg&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To analyze .Net assemblies we need to load .Net extensions by typing .load sos and hitting Enter:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="96" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_thumb_1.png" width="229" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Enumerate threads&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Run !threads command to enlist available threads:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_6.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="109" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_thumb_2.png" width="350" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;and then choose specific thread - use left most column for thread identification as follows ~[thread number goes here]s:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_8.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="97" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_thumb_3.png" width="330" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Enumerate objects in thread&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Use !dso command to dump all objects in the thread:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_10.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="143" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_thumb_4.png" width="412" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Dump object's values&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Use !do &amp;lt;object address&amp;gt; to dump specific object's values. Object address is a second column in the list generated by !dso command, the column named "Object" - just copy and paste it:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_14.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="271" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/AvoidManipulatingPasswordsInMemoryItisEa_1032B/image_thumb_6.png" width="328" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The password is revealed either by attaching to the process or analyzing a crash file that was taken offsite.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Countermeasures and guidelines&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;As rule of thumb avoid using custom built identification and authentication mechanisms and leverage those that the infrastructure offers - preferably Windows Integrated authentication. In case where all options exhausted and there is no other way but accept end user credentials, refer to the following article - &lt;a href="http://msdn2.microsoft.com/en-us/library/aa302353.aspx" target="_blank"&gt;Using Credential Management in Windows XP and Windows Server 2003&lt;/a&gt;. Techniques described in the article allow to leverage built in mechanism of accepting credentials from end user in more secure manner. It also keeps common familiar look and feel across custom application and built in Windows mechanisms leaving less room for end user confusion.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;My related posts:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/04/11/authentication-hub.aspx"&gt;Authentication Hub&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Other resources:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;This post is inspired by &lt;a href="http://blogs.msdn.com/johan/archive/2007/11/13/getting-started-with-windbg-part-i.aspx" target="_blank"&gt;Getting started with windbg - part I&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/johan/archive/2007/11/13/getting-started-with-windbg-part-ii.aspx" target="_blank"&gt;Getting started with windbg - part II&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://kentb.blogspot.com/2007/11/windbg-sos-cheat-sheet.html" target="_blank"&gt;WinDbg + SOS Cheat Sheet&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.securityguidanceshare.com/wiki/ASP.NET_2.0_Security_Questions_and_Answers_-_Sensitive_Data" target="_blank"&gt;ASP.NET 2.0 Security Questions and Answers - Sensitive Data&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.securityguidanceshare.com/wiki/ASP.NET_2.0_Security_Questions_and_Answers_-_Authentication" target="_blank"&gt;ASP.NET 2.0 Security Questions and Answers - Authentication&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6701111" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Sensitive+Data/default.aspx">Sensitive Data</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Authentication/default.aspx">Authentication</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item><item><title>Composite Application Block (CAB) Programming Essentials - Crucial For CAB Performance</title><link>http://blogs.msdn.com/alikl/archive/2007/10/29/composite-application-block-cab-programming-essentials-crucial-for-cab-performance.aspx</link><pubDate>Mon, 29 Oct 2007 23:30:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5770532</guid><dc:creator>alikl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/alikl/comments/5770532.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=5770532</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=5770532</wfw:comment><description>&lt;p&gt;&lt;a href="http://richnewman.wordpress.com/" target="_blank"&gt;Rich Newman&lt;/a&gt;&lt;font color="#666666"&gt;&amp;nbsp;&lt;/font&gt; posted awesome guides for Composite Application Block (CAB) programming:&lt;/p&gt; &lt;blockquote&gt; &lt;h5&gt;&lt;a href="http://richnewman.wordpress.com/intro-to-cab-toc/" target="_blank"&gt;Table of Contents: Introduction to CAB/SCSF&lt;/a&gt;&lt;/h5&gt;&lt;/blockquote&gt; &lt;blockquote&gt; &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/07/14/an-introduction-to-the-smart-client-software-factory-and-composite-application-block-part-1-modules-and-shells/" target="_blank"&gt;Part 1 Modules and Shells&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/07/14/an-introduction-to-the-smart-client-software-factory-and-composite-application-block-part-2-workitems/" target="_blank"&gt;Part 2 WorkItems&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/07/21/introduction-to-dependency-injection-introduction-to-cabscsf-part-3/" target="_blank"&gt;Part 3 Introduction to Dependency Injection&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/08/04/an-aside-on-inversion-of-control-dependency-inversion-and-dependency-injection-introduction-to-cabscsf-part-4/" target="_blank"&gt;Part 4 An Aside on Inversion of Control, Dependency Inversion and Dependency Injection&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/08/05/dependency-injection-and-the-composite-application-block-introduction-to-cabscsf-part-5/" target="_blank"&gt;Part 5 Dependency Injection and the Composite Application Block&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/09/04/constructor-injection-in-the-cab-introduction-to-the-cabscsf-part-6/" target="_blank"&gt;Part 6 Constructor Injection in the Composite Application Block&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/09/08/introduction-to-services-in-the-cab-introduction-to-the-cabscsf-part-7/" target="_blank"&gt;Part 7 Introduction to Services in the Composite Application Block&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/09/09/creating-and-using-services-in-the-cab-introduction-to-the-cabscsf-part-8/" target="_blank"&gt;Part 8 Creating and Using Services in the Composite Application Block&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/09/15/the-command-design-pattern-introduction-to-the-cabscsf-part-9/" target="_blank"&gt;Part 9 The Command Design Pattern&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/09/16/commands-in-the-cab-introduction-to-cabscsf-part-10/" target="_blank"&gt;Part 10 Commands in the Composite Application Block&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/09/22/introduction-to-events-in-the-cab-introduction-to-cabscsf-part-11/" target="_blank"&gt;Part 11 Introduction to Events in the Composite Application Block&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/09/23/events-in-the-cab-introduction-to-cabscsf-part-12/" target="_blank"&gt;Part 12 Events in the Composite Application Block&lt;/a&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://richnewman.wordpress.com/2007/10/13/introduction-to-uiextensionsites-introduction-to-the-cabscsf-part-13/" target="_blank"&gt;Part 13 Introduction to UIExtensionSites&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;It is important to understand these core principles. Recently I was involved with a project where CAB was used extensively. Too extensively... The application was actually over-CAB'ed causing performance hit. When we ran the &lt;a href="http://www.jetbrains.com/profiler/" target="_blank"&gt;profiler&lt;/a&gt; we saw that many functions calls were empty while adding up to execution time. The only solution was redesigning the application and CAB usage.&lt;/p&gt; &lt;p&gt;Lessons Learned:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Do not over CAB&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Load modules on demand&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Cache static data&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Related resources:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/eugeniop/archive/2006/08/23/716037.aspx" target="_blank"&gt;Notes on (extreme) Performance requirements for CAB&lt;/a&gt;&lt;/strong&gt;  &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=f9176708-9f57-4c0f-97fb-f9c65a9bbf22&amp;amp;displaylang=en" target="_blank"&gt;Mobile Client Software Factory&lt;/a&gt;&amp;nbsp;(includes includes CABgen and OBgen for NGEN'ing CAB modules)  &lt;li&gt;&lt;a href="http://staff.southworks.net/blogs/matiaswoloski/archive/2006/02/26/CABModulesOnDemand.aspx" target="_blank"&gt;How To: load CAB modules on demand&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5770532" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Deployment+Phase/default.aspx">Deployment Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item><item><title>Authentication And Identity Flow When ASP Page Consumes ASP.NET Web Service</title><link>http://blogs.msdn.com/alikl/archive/2007/09/05/authentication-and-identity-flow-when-asp-page-consumes-asp-net-web-service.aspx</link><pubDate>Wed, 05 Sep 2007 19:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4765827</guid><dc:creator>alikl</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/alikl/comments/4765827.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=4765827</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=4765827</wfw:comment><description>&lt;P&gt;"Classic" ASP has&amp;nbsp;application isolation that is different from ASP.NET. Here is one of the&amp;nbsp;real world scenarios&amp;nbsp;where it might matter.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/IdentityFlowWhenASPPageCon.NETWebService_CB38/image.png" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/IdentityFlowWhenASPPageCon.NETWebService_CB38/image.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=178 alt=image src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/IdentityFlowWhenASPPageCon.NETWebService_CB38/image_thumb.png" width=408 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/IdentityFlowWhenASPPageCon.NETWebService_CB38/image_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;There is a legacy web application written in ASP and hosted on Win2K3 box (IIS 6.0). It is of course in the process of migration to ASP.NET. As part of the migration process there were several ASP.NET web services factored out of the classic ASP app. These web services are hosted on another Win2K3 box and require windows authentication. Classic ASP must consume these web services while satisfying the requirement of windows authentication. ASP page consumes the web service via .Net COM interop invoking .Net component:&lt;/P&gt;
&lt;P&gt;The question here is what is this account that ASP page authenticates to ASP.NET web service&amp;nbsp;on another machine?&lt;/P&gt;
&lt;P&gt;It is common mistake assuming that the account is the application pool's one. ASP does not run in the context of the application pool. In case of anonymous access It runs in the context of what defined for anonymous user:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/IdentityFlowWhenASPPageCon.NETWebService_CB38/image_1.png" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/IdentityFlowWhenASPPageCon.NETWebService_CB38/image_1.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=333 alt=image src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/IdentityFlowWhenASPPageCon.NETWebService_CB38/image_thumb_1.png" width=279 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/IdentityFlowWhenASPPageCon.NETWebService_CB38/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Said that, in order to let ASP page authenticate to ASP.NET web service based on windows authentication one needs to define domain account in above property page for virtual directory where ASP resides. This is the account that will hit the ASP.NET web service.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4765827" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Deployment+Phase/default.aspx">Deployment Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Authentication/default.aspx">Authentication</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Planning+Phase/default.aspx">Planning Phase</category></item></channel></rss>