<?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 : Test Phase</title><link>http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx</link><description>Tags: Test Phase</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How To Generate Unit Test Using WCF Load Test – Quick Steps</title><link>http://blogs.msdn.com/alikl/archive/2009/06/29/how-to-generate-unit-test-using-wcf-load-test-quick-steps.aspx</link><pubDate>Mon, 29 Jun 2009 09:13:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9808237</guid><dc:creator>alikl</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/alikl/comments/9808237.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=9808237</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=9808237</wfw:comment><description>&lt;table border="0" cellspacing="5" cellpadding="2" width="557"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="226"&gt;&amp;#160;&lt;a href="http://practicethis.com/" rel="external nofollow" target="_blank"&gt;&lt;img title="Alik Levin" border="0" alt="Alik Levin" src="http://blogs.microsoft.co.il/blogs/mcs/WindowsLiveWriter/d20b00ba5cce_FD44/image_5.png" width="50" height="50" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160; This is quick summary of steps for creating WCF Unit Tests using &lt;a href="http://wcfloadtest.codeplex.com/"&gt;WCF Load Test&lt;/a&gt; available for free on Codeplex. This quick summary created based on the Lab materials that ship with the &lt;a href="http://wcfloadtest.codeplex.com/"&gt;tool&lt;/a&gt;.&lt;/td&gt;        &lt;td valign="top" width="314"&gt;         &lt;p&gt;&lt;strong&gt;Quick Resource Box&lt;/strong&gt;&lt;/p&gt;          &lt;ul&gt;           &lt;li&gt;&lt;a href="http://wcfloadtest.codeplex.com/"&gt;WCF Load Test&lt;/a&gt; &lt;/li&gt;         &lt;/ul&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td colspan="2"&gt;         &lt;h3&gt;Summary of steps&lt;/h3&gt;          &lt;ul&gt;           &lt;li&gt;&lt;strong&gt;Step 1. Configure message tracing in the app.config file on client side.&lt;/strong&gt; &lt;/li&gt;            &lt;li&gt;&lt;strong&gt;Step 2. Run WCF client to invoke the remote methods and generate trace file.&lt;/strong&gt; &lt;/li&gt;            &lt;li&gt;&lt;strong&gt;Step 3. Generate Unit test based on trace file.&lt;/strong&gt; &lt;/li&gt;         &lt;/ul&gt;          &lt;h3&gt;&lt;strong&gt;Step 1. Configure message tracing in the app.config file on client side. &lt;/strong&gt;&lt;/h3&gt;          &lt;ol&gt;           &lt;li&gt;Select the &lt;b&gt;Diagnostics&lt;/b&gt; folder. &lt;/li&gt;            &lt;li&gt;Under &lt;b&gt;Message Logging&lt;/b&gt; click &lt;b&gt;Enable Message Logging&lt;/b&gt;. &lt;/li&gt;            &lt;li&gt;Click &lt;b&gt;Log Level&lt;/b&gt; and check &lt;b&gt;Service messages&lt;/b&gt;. The other options can be unchecked. &lt;/li&gt;            &lt;li&gt;Click &lt;b&gt;ServiceModelMessageLoggingListener&lt;/b&gt; and change the file name to be “WCFClient.svclog”. &lt;/li&gt;            &lt;li&gt;Under the Message Logging folder enable &lt;b&gt;LogEntireMessage&lt;/b&gt;. &lt;/li&gt;            &lt;li&gt;Save the configuration file. &lt;/li&gt;         &lt;/ol&gt;          &lt;h3&gt;&lt;strong&gt;Step 2. Run WCF client to invoke the remote methods and generate trace file.&lt;/strong&gt;&lt;/h3&gt;          &lt;p&gt;Run your WCF client. Make sure WCFClient.svclog generated. This log file will be used in the next step to generate Unit Tests&lt;/p&gt;          &lt;h3&gt;&lt;strong&gt;Step 3. Generate Unit test based on trace file.&lt;/strong&gt;&lt;/h3&gt;          &lt;ul&gt;           &lt;li&gt;Create a new test project in Visual Studio. &lt;/li&gt;            &lt;li&gt;Add a reference to the following assemblies:              &lt;ul&gt;               &lt;li&gt;System.ServiceModel &lt;/li&gt;                &lt;li&gt;System.Runtime.Serialization (version 3.0.0.0) &lt;/li&gt;             &lt;/ul&gt;           &lt;/li&gt;            &lt;li&gt;In the directory containing the test project create a file called SampleConfig.xml with the following contents:&amp;#160; &lt;/li&gt;         &lt;/ul&gt;          &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #a31515"&gt;xml &lt;/span&gt;&lt;span style="color: red"&gt;version&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;'&lt;span style="color: blue"&gt;1.0&lt;/span&gt;' &lt;span style="color: red"&gt;encoding&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;'&lt;span style="color: blue"&gt;utf-8&lt;/span&gt;' &lt;span style="color: blue"&gt;?&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WcfUnitConfiguration &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;'&lt;span style="color: blue"&gt;http://microsoft.com/wcfunit&lt;/span&gt;'
                           &lt;span style="color: red"&gt;testMethodMode&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;'&lt;span style="color: blue"&gt;ScenarioMethodOnly&lt;/span&gt;'
                           &lt;span style="color: red"&gt;operationTimerMode&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;'&lt;span style="color: blue"&gt;IncludeOperationTimers&lt;/span&gt;'&lt;span style="color: blue"&gt;&amp;gt;
       &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;assembly &lt;/span&gt;&lt;span style="color: red"&gt;fileName&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;C:\Client\bin\Debug\ConsoleClient.exe&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;/&amp;gt;
     &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;soapActions &lt;/span&gt;&lt;span style="color: red"&gt;soapActionMode&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;'&lt;span style="color: blue"&gt;Include&lt;/span&gt;'&lt;span style="color: blue"&gt;&amp;gt;
     &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;soapActions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WcfUnitConfiguration&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;ul&gt;
          &lt;li&gt;Open an SDK command prompt and change the directory to the one containing the test project. &lt;/li&gt;

          &lt;li&gt;Execute the following command: 
            &lt;br /&gt;&lt;em&gt;svcutil /o:proxy.cs /config:app.config http://localhost:8090/service?wsdl &lt;/em&gt;&lt;/li&gt;

          &lt;li&gt;Run the command-line tool using the following command: 
            &lt;br /&gt;“c:\program files\wcfunit\wcfunit” CompileTimeScenario &amp;lt;trace file&amp;gt; SampleConfig.xml where the &amp;lt;trace file&amp;gt; is the path to the WCFClient.svclog file created in the previous exercise. &lt;/li&gt;

          &lt;li&gt;Add generated files (CompileTimeScenario.cs and CompileTimeScenario.stubs) to the test project. &lt;/li&gt;

          &lt;li&gt;Rename CompileTimeScenario.stubs to CompileTimeScenario.Stubs.cs. &lt;/li&gt;

          &lt;li&gt;Also add the proxy.cs and app.config files located in the client project folder to the test project. &lt;/li&gt;

          &lt;li&gt;Build the solution and a Unit Test called CompileTimeScenario should appear in the Test View. &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9808237" 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/Test+Phase/default.aspx">Test Phase</category></item><item><title>DebugView - Free Simple Tool To Quickly Identify Performance Problems</title><link>http://blogs.msdn.com/alikl/archive/2008/11/11/debugview-free-simple-tool-to-quickly-identify-performance-problems.aspx</link><pubDate>Tue, 11 Nov 2008 18:12:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9060327</guid><dc:creator>alikl</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/alikl/comments/9060327.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=9060327</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=9060327</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; &lt;a href="http://www.microsoft.com/technet/sysinternals/Miscellaneous/DebugView.mspx"&gt;DebugView is well known free tool from Systinternals (Microsoft)&lt;/a&gt;. Vast majority of developers is aware of its existence. Nevertheless, I've decided to write this post following my practice of journaling my technical accomplishments during engagements with the customers. Yesterday the tool helped us identify serious performance problem without installing profiler or even taking memory dumps.&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;h3&gt;Customer Case Study&lt;/h3&gt;  &lt;p&gt;The customer complained about &amp;quot;bad performance&amp;quot; of web pages. The application was pretty simple one - ASP.NET pages accessing SQL Server for simple queries. The SQL Server was installed on the same machine where ASP.NET app resided. The pages took up to ten seconds to render.&lt;/p&gt;  &lt;h3&gt;Analysis&lt;/h3&gt;  &lt;p&gt;After quick code review we found out that the code called function that traversed all server controls using recursion. This function was called several times during the page lifecycle. I presented the team with my assumption that this code is a potential culprit of the &amp;quot;bad performance&amp;quot;. The opposite assumption I faced was &amp;quot;but there is only so few controls on the page, it cannot consume too much time.&amp;quot;&lt;/p&gt;  &lt;p&gt;We decided to add single line of code to the function in question:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;System.Diagnostics.Trace.WriteLine (&amp;quot;Calling Recursive Function&amp;quot;);&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Then we fired up DebugView and ran the page.&lt;/p&gt;  &lt;p&gt;The team was amazed by what DebugView presented interactively. &amp;quot;Calling Recursive Function&amp;quot; line kept piling up on and on. Each call took from 50 to 100 milliseconds but when multiplied to overall number of calls (~700) it gave us clear understanding what caused the performance hit.&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;Instrument your application properly - simple yet powerful technique that helps you avoid calling expensive consultants onsite. &lt;/p&gt;  &lt;p&gt;Instrument your application and surprise your end users by high performing application.&lt;/p&gt;  &lt;h3&gt;Related Materials&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;&amp;#160;&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/2008/11/03/asp-net-performance-by-design-takeaways-from-pdc.aspx"&gt;ASP.NET Performance By Design: Takeaways From PDC&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;This post 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=9060327" 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/Performance/default.aspx">Performance</category></item><item><title>ASP.NET Performance: Dynamically Loaded Assemblies Cause Application Recycles (Problem and Solution)</title><link>http://blogs.msdn.com/alikl/archive/2008/10/08/asp-net-performance-dynamically-loaded-assemblies-cause-application-recycles-problem-and-solution.aspx</link><pubDate>Wed, 08 Oct 2008 16:21:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8991289</guid><dc:creator>alikl</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8991289.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8991289</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8991289</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; In my speak - dynamically loaded assemblies are those assemblies that were compiled during run time dynamically via CodeProvider like CSharpCodeProvider directly or by using types that use this class internally. Assemblies that are loaded dynamically using reflection via Load/LoadFrom method are out of the scope of this post. &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;h3&gt;Customer Case Study&lt;/h3&gt;  &lt;p&gt;The customer complained on periodic restarts/recycles of the ASP.NET application. We observed relative entries in the Event Log that showed up systematically on timely basis. We also observed memory utilization growth in Task Manager. After reaching 500 MB of memory utilization the application would recycle spawning another w3wp.exe to accept new incoming requests while draining the old w3wp.exe.&lt;/p&gt;  &lt;h3&gt;Analysis&lt;/h3&gt;  &lt;p&gt;After short discussion with the dev team about the design of the application we thought that the memory leak might be caused by improper usage of XmlSerializer that generate dynamic assemblies. Tess published &lt;a href="http://blogs.msdn.com/tess/archive/2008/03/17/net-debugging-demos-lab-6-memory-leak-review.aspx"&gt;fantastic walk through&lt;/a&gt; specifically dedicated to this case. Using either perfmon (.NET CLR Loading\Current Assemblies) or Process Explorer (see pic below)we observed unusual number (thousands) of loaded assemblies (notice Assemblies column). Also, notice the csc.exe in red - this is CSharp compiler that is invoked on each request:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.NETPerformanceDynamicallyLoadedAssem_928B/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="226" alt="Process Explorer ASP.NET Performance Dynamically Loaded Assemblies" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.NETPerformanceDynamicallyLoadedAssem_928B/image_thumb.png" width="567" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We decided to take a memory dump to deeply investigate the case. Following are the steps that we took while analyzing the dump using WinDBG to identify the root cause:&lt;/p&gt;  &lt;h4&gt;Step 1 - Dumping memory heap to identify object allocated on heap&lt;/h4&gt;  &lt;p&gt;This is the fragment of the long list of objects. Our attention was caught by unusually large number of reflected assemblies.&lt;/p&gt;  &lt;ul&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/ul&gt;  &lt;p&gt;&lt;b&gt;!dumpheap &amp;#8211;stat      &lt;br /&gt;&lt;/b&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;9,019&lt;/font&gt;&lt;/b&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 216,456 System.Reflection.Assembly     &lt;br /&gt;112&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 4,032 System.Xml.Serialization.TempAssembly     &lt;br /&gt;104&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 5,408 System.Xml.Serialization.TypeDesc&lt;/p&gt;  &lt;p&gt;After 3 minutes the number of dynamic assemblies is larger by more 350 assemblies (from subsequent dump):&lt;/p&gt;  &lt;p&gt;&lt;b&gt;!dumpheap &amp;#8211;stat      &lt;br /&gt;&lt;/b&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;9,379&lt;/font&gt;&lt;/b&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 225,096 System.Reflection.Assembly     &lt;br /&gt;114&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 4,104 System.Xml.Serialization.TempAssembly     &lt;br /&gt;102&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 5,304 System.Xml.Serialization.TypeDesc&lt;/p&gt;  &lt;h4&gt;Step 2 - Dumping appdomains to identify loaded assemblies&lt;/h4&gt;  &lt;p&gt;Another cross check to make sure we are dealing with tons of loaded assemblies.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;!dumpdomain -stat&amp;#160; &lt;br /&gt;&lt;/b&gt;&amp;#160;&amp;#160;&amp;#160; Domain&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; Num Assemblies&amp;#160;&amp;#160; Size Assemblies&amp;#160;&amp;#160;&amp;#160; Name     &lt;br /&gt;0x793f15d8&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;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 1&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;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2,142,208&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System Domain     &lt;br /&gt;0x793f2aa8&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;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 56&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;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 16,012,288&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Shared Domain     &lt;br /&gt;0x000ab7d8&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;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2&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;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2,498,560&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DefaultDomain     &lt;br /&gt;0x000d3368&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;&amp;#160;&amp;#160; &lt;b&gt;&lt;font color="#ff0000"&gt;9,018&lt;/font&gt;&lt;/b&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;&amp;#160;&amp;#160; 55,447,040&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /LM/W3SV......&lt;/p&gt;  &lt;p&gt;Total 4 Domains, Total Size 76,100,096&lt;/p&gt;  &lt;h4&gt;Step 3 - Dumping all dynamic assemblies&lt;/h4&gt;  &lt;p&gt;How many of the assemblies are dynamic? (dda stands for dumpdynamicassemblies)&lt;/p&gt;  &lt;p&gt;&lt;b&gt;!dda&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="1"&gt;Domain: 0x793f15d8      &lt;br /&gt;-------------------       &lt;br /&gt;Domain: .       &lt;br /&gt;-------------------       &lt;br /&gt;Domain: DefaultDomain       &lt;br /&gt;-------------------       &lt;br /&gt;Domain: /LM/W3SVC/1/ROOT/......       &lt;br /&gt;-------------------       &lt;br /&gt;Assembly: 0x19058818 [RegexAssembly133_0] Dynamic Module: 0x16f4c220 loaded at: 0x0 Size: 0x0((null))       &lt;br /&gt;&lt;/font&gt;&lt;font size="1"&gt;Assembly: 0x19058818 [RegexAssembly133_0] Dynamic Module: 0x190696a0 loaded at: 0x0 Size: 0x0((null))      &lt;br /&gt;&lt;/font&gt;&lt;font size="1"&gt;Assembly: 0x19103ee8 [-0g5u8-v] Dynamic Module: 0x1920d6f8 loaded at: 0x19911000 Size: 0xc000((null))      &lt;br /&gt;&lt;/font&gt;&lt;font size="1"&gt;Assembly: 0x190c9a40 [cvmmynwf] Dynamic Module: 0x190dc0d0 loaded at: 0x19a71000 Size: 0x4000((null))      &lt;br /&gt;&lt;/font&gt;&lt;font size="1"&gt;Assembly: 0x1911bad8 [0ikhy_lx] Dynamic Module: 0x1911aa98 loaded at: 0x19f21000 Size: 0xc00((null))      &lt;br /&gt;&lt;/font&gt;&lt;font size="1"&gt;.......      &lt;br /&gt;&lt;/font&gt;&lt;font size="1"&gt;Assembly: 0x43199720 [nv1lvdiy] Dynamic Module: 0x431b3190 loaded at: 0x4cf61000 Size: 0xc00((null))      &lt;br /&gt;&lt;/font&gt;&lt;font size="1"&gt;Assembly: 0x2d2bf008 [rk6dabem] Dynamic Module: 0x2d2bf258 loaded at: 0x4cf71000 Size: 0xc00((null))      &lt;br /&gt;&lt;/font&gt;&lt;font size="1"&gt;--------------------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Total &lt;font color="#ff0000"&gt;8,911 Dynamic Assemblies&lt;/font&gt;, Total size: 0x1d5b600(30,782,976) bytes.&lt;/b&gt;&lt;/p&gt;  &lt;h4&gt;Step 4 - Saving dynamic assembly to physical DLL&lt;/h4&gt;  &lt;p&gt;Save assemblies to the filesystem&lt;/p&gt;  &lt;p&gt;&lt;b&gt;!savemodule 0x2d2bc4c8 C: \0x1c344438.dll&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;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.NETPerformanceDynamicallyLoadedAssem_928B/clip_image002_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="86" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.NETPerformanceDynamicallyLoadedAssem_928B/clip_image002_thumb.jpg" width="490" border="0" /&gt;&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;To save all the assemblies to the file system use the following command: &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;!dda -save C:\MODULES&lt;/strong&gt;&lt;/p&gt;  &lt;h4&gt;Step 5 - Using Reflector to reverse engineer the DLL:&lt;/h4&gt;  &lt;p&gt;Use Reflector to inspect the implementation/source code of the dynamic assemblies.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.NETPerformanceDynamicallyLoadedAssem_928B/clip_image001_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="220" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.NETPerformanceDynamicallyLoadedAssem_928B/clip_image001_thumb.jpg" width="403" border="0" /&gt;&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h4&gt;Step 6 - Using Reflector to find&amp;#160; ExpressionEvaluator class&lt;/h4&gt;  &lt;p&gt;Try to locate the class in the static assemblies hopefully hitting the code that generates it:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.NETPerformanceDynamicallyLoadedAssem_928B/image_4.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/ASP.NETPerformanceDynamicallyLoadedAssem_928B/image_thumb_1.png" width="529" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h4&gt;Step 7 - Bingo! Each constructor for ExpressionEvaluator invokes compiler&lt;/h4&gt;  &lt;p&gt;ICodeCompiler compiler = new CSharpCodeProvider().CreateCompiler();    &lt;br /&gt;...     &lt;br /&gt;CompilerResults results = compiler.CompileAssemblyFromSource(options, builder.ToString());    &lt;br /&gt;...    &lt;br /&gt;this._Compiled = results.CompiledAssembly.CreateInstance(&amp;quot;NavServices._ExpressionEvaluator&amp;quot;);&lt;/p&gt;  &lt;p&gt;This is actually the code that causes Process Explorer to show csc.exe under w3wp.exe (see red line in the first pic). And this is the code that caused number of loaded assemblies to grow. And this is the code that caused the application restarts.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h3&gt;Acknowledgements&lt;/h3&gt;  &lt;p&gt;During this investigation the following resources were used. Big THANK-YOU goes to:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Tess - &lt;a href="http://blogs.msdn.com/tess/archive/2006/02/15/net-memory-leak-xmlserializing-your-way-to-a-memory-leak.aspx"&gt;.NET Memory Leak: XmlSerializing your way to a Memory Leak&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Tom - &lt;a title="http://blogs.msdn.com/tom/archive/2007/12/05/dynamic-assemblies-and-what-to-do-about-them.aspx" href="http://blogs.msdn.com/tom/archive/2007/12/05/dynamic-assemblies-and-what-to-do-about-them.aspx"&gt;Dynamic Assemblies and what to do about them&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Johan - &lt;a href="http://blogs.msdn.com/johan/archive/2007/11/13/getting-started-with-windbg-part-i.aspx"&gt;Getting started with windbg - part I&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Cuko - &lt;a href="http://blogs.msdn.com/baleixo/archive/2008/07/18/outofmemory-compiledassembly.aspx"&gt;OutOfMemory &amp;amp; CompiledAssembly&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Related Materials&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="http://blogs.msdn.com/ace_team/archive/2008/08/11/asp-net-performance-high-cpu-utilization-case-studies-and-solutions.aspx" 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;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;/ul&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=8991289" 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></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>Security Code Review – String Search Patterns For Authorization Vulnerabilities</title><link>http://blogs.msdn.com/alikl/archive/2008/07/24/security-code-review-string-search-patterns-for-authorization-vulnerabilities.aspx</link><pubDate>Thu, 24 Jul 2008 22:53:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8769967</guid><dc:creator>alikl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8769967.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8769967</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8769967</wfw:comment><description>&lt;p&gt;These are the &lt;a href="http://msdn.microsoft.com/en-us/library/ms998375.aspx" target="_blank"&gt;questions&lt;/a&gt; and the search criteria I use to identify authorization vulnerabilities in the code beyond web.config &amp;lt;authorization&amp;gt; node.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;How does the code protect access to page classes?&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Attributes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Search for PrincipalPermission attributes. If there is no match, the code does not perform standard authorization checks.&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;PrincipalPermission&amp;quot; *.cs&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Empirical checks&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Search for empirical IsInRole calls. If there is no match, the code does not perform standard authorization checks.&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;IsInRole&amp;quot; *.cs&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Rolemanager&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Search for empirical IsUserInRole calls for Rolemanager API. If there is no match, the code does not perform standard authorization checks.&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;IsUserInRole&amp;quot; *.cs&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Does the code use Server.Transfer?&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;When the code uses Server.Transfer it may improve performance but potentially it may pose a threat of elevation of privileges, more info is here &lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/27/performance-gain-security-risk.aspx" target="_blank"&gt;Performance Gain - Security Risk&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;Transfer&amp;quot; *.cs&lt;/p&gt;  &lt;h3&gt;Related posts&lt;/h3&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/07/11/security-code-review-string-search-patterns-for-finding-input-validation-vulnerabilities.aspx"&gt;Security Code Review – String Search Patterns For Finding Input Validation Vulnerabilities&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/07/21/security-code-review-string-search-patterns-for-authentication-vulnerabilities.aspx"&gt;Security Code Review – String Search Patterns For Authentication Vulnerabilities&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/05/30/soa-strong-authentication-standard-authorization-cool-solution.aspx"&gt;SOA, Strong Authentication, Standard Authorization - Cool Solution&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/04/11/authentication-hub.aspx" target="_blank"&gt;Authentication Hub&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8769967" 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/Authorization/default.aspx">Authorization</category></item><item><title>Security Code Review – String Search Patterns For Authentication Vulnerabilities</title><link>http://blogs.msdn.com/alikl/archive/2008/07/21/security-code-review-string-search-patterns-for-authentication-vulnerabilities.aspx</link><pubDate>Mon, 21 Jul 2008 15:39:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8761384</guid><dc:creator>alikl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8761384.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8761384</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8761384</wfw:comment><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;This post contains string search patterns that can help identifying authentication vulnerabilities during &lt;a href="http://msdn.microsoft.com/en-us/library/ms998375.aspx" target="_blank"&gt;security code inspection for your ASP.NET application&lt;/a&gt;. Most common vulnerability is about insecurely manipulating credentials in the code. The question we want to actually ask is:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Are you passing clear text credentials?&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The associated &lt;strong&gt;&lt;em&gt;threat&lt;/em&gt;&lt;/strong&gt; is identity theft or identity spoof that can be achieved by disclosing the credentials or/and tampering it.&lt;/p&gt;  &lt;h3&gt;What to Search for and Why&lt;/h3&gt;  &lt;p&gt;Credentials are usually required when accessing a down stream resource – database, web service, active directory, MQSeries, or any other. This information can be easily obtained from the architecture document. Following are possible searches that can lead you to the hotspots to nail potential authentication vulnerabilities:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;DB Connections&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;.Open( &amp;quot; *.cs&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Web Services&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;.Credentials =&amp;quot; *.cs&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;LogonUser API – usually used for impersonation&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;LogonUser&amp;quot; *.cs&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;IIdentity usage&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This one is my favorite. This search pattern is actually trying to spot the anti-pattern of identifying end user. The assumption here is that when there is no matches for that search then the solution either does not identifies the requests or uses home grown solution which might be potential vulnerability in both cases.&lt;/p&gt;  &lt;p&gt;findstr /S /I “.Identity&amp;quot; *.cs&lt;/p&gt;  &lt;p&gt;Other than above searches it is good idea to review the web.config file for potential clear text credentials.&lt;/p&gt;  &lt;p&gt;Got more suggestions for search patters to identify potential authentication vulnerabilities? - Please, share!&lt;/p&gt;  &lt;h3&gt;Related posts&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/07/11/security-code-review-string-search-patterns-for-finding-input-validation-vulnerabilities.aspx" target="_blank"&gt;Security Code Review – String Search Patterns For Finding Input Validation Vulnerabilities&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/12/08/avoid-manipulating-passwords-in-memory-it-is-easy-to-reveal.aspx" target="_blank"&gt;Avoid Manipulating Passwords In Memory - It Is Easy To Reveal&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/09/05/authentication-and-identity-flow-when-asp-page-consumes-asp-net-web-service.aspx" target="_blank"&gt;Authentication And Identity Flow When ASP Page Consumes ASP.NET Web Service&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/05/31/security-educational-workshop-authentication-explained.aspx" target="_blank"&gt;Security Educational Workshop - Authentication Explained&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/05/30/soa-strong-authentication-standard-authorization-cool-solution.aspx" target="_blank"&gt;SOA, Strong Authentication, Standard Authorization - Cool Solution&lt;/a&gt; &lt;/li&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;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8761384" 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/Authentication/default.aspx">Authentication</category></item><item><title>Use FREE Tools From IIS Resource Kit To Warm Up Your ASP.NET 1.1 Application By Batch Compilation</title><link>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</link><pubDate>Sun, 20 Jul 2008 18:24:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8758682</guid><dc:creator>alikl</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8758682.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8758682</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8758682</wfw:comment><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;Have you noticed that when ASP.NET web application is accessed for the first time the response is slow? The reason for such behavior is batch compilation that occurs on the first hit.&lt;/p&gt;  &lt;p&gt;ASP.NET batch compilation is the process of compiling ASP.NET markup (content of aspx files) into temporary dll’s. Compilation requires invoking compiler (csc.exe for C#) – that is pretty heavy activity. &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" target="_blank"&gt;Process Explorer&lt;/a&gt; shows it clearly:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.1BatchCompilationWarmYourWebApplicat_11CE0/image_2.png"&gt;&lt;img title="ASP.NET Batch compilation" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="57" alt="ASP.NET Batch compilation" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.1BatchCompilationWarmYourWebApplicat_11CE0/image_thumb.png" width="550" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;ASP.NET batch compilation occurs on per folder basis. Said that, if your application divided into multiple sub-folders that contain ASP.NET pages each time any of the folders accessed for the first time the batch compilation is invoked.&lt;/p&gt;  &lt;p&gt;Note that starting with &lt;font color="#ff0000"&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163675.aspx" target="_blank"&gt;ASP.NET 2.0 compilation model&lt;/a&gt;&lt;/font&gt; has changed. Also, there is a tool &lt;a href="http://msdn.microsoft.com/en-us/library/ms229863(VS.80).aspx" target="_blank"&gt;Aspnet_compiler.exe&lt;/a&gt; that allows pre-compile your ASP.NET web application to improve performance.&lt;/p&gt;  &lt;h3&gt;Customer’s case study&lt;/h3&gt;  &lt;p&gt;Customer’s web application is built with ASP.NET 1.1. It is divided into multiple subfolders reflecting logical modules that are hosted across about 20 application pools. The application connects to Oracle database. &lt;/p&gt;  &lt;p&gt;QA team complains that the application responds slowly each time any of the modules (subfolders) accessed for the first time.&lt;/p&gt;  &lt;p&gt;Using Process Explorer and profiler we identified three main latency points:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Creating the application pool – w3wp.exe. &lt;/li&gt;    &lt;li&gt;Batch compiling the application for each subfolder. &lt;/li&gt;    &lt;li&gt;Creating Oracle connection pool when Oracle is accessed for the first time. &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;The solution&lt;/h3&gt;  &lt;p&gt;We decided to create a Warmer – solution that will hit each subfolder’s page in unattended manner thus warming up the application before the first user hits it.&lt;/p&gt;  &lt;p&gt;For the solution we used free tools from &lt;font color="#ff0000"&gt;&lt;strong&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=56FC92EE-A71A-4C73-B628-ADE629C89499&amp;amp;displaylang=en" target="_blank"&gt;IIS resource&lt;/a&gt;&lt;/strong&gt;&lt;/font&gt; kit:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;amp;displaylang=en" target="_blank"&gt;LogPrser.exe&lt;/a&gt;&lt;/strong&gt; to identify the URL’s of the pages to hit. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;&lt;a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/993a8a36-5761-448f-889e-9ae58d072c09.mspx?mfr=true" target="_blank"&gt;TinyGet.exe&lt;/a&gt;&lt;/strong&gt; to actually hit the pages identified by LogParser. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;To identify what pages to hit we took IIS log files from QA environment and than we ran the following query using LogParser:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;LogParser.exe &amp;quot;SELECT DISTINCT STRCAT('XXX', cs-uri-stem) AS cs-uri-stem-strcat INTO 'C:\result.txt' FROM 'C:\yourIISlogFile.log' WHERE INDEX_OF(cs-uri-stem, 'aspx') &amp;gt; 0&amp;quot; -o:w3c&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Notice XXX – it has nothing to do with XXX rated content rather it is a placeholder to replace it with tinyget command.&lt;/p&gt;  &lt;p&gt;Open resulting yourIISlogFile.log file in Notepad, hit Ctrl+H for “Replace” and replace all occurrences of XXX with the following command:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;tinyget -srv:www.YourServer.com -uri:&lt;/p&gt;    &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.1BatchCompilationWarmYourWebApplicat_11CE0/image_10.png"&gt;&lt;img title="ASP.NET Batch Compilation" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="193" alt="ASP.NET Batch Compilation" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.1BatchCompilationWarmYourWebApplicat_11CE0/image_thumb_4.png" width="365" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;yourIISlogFile.log before the Replace:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.1BatchCompilationWarmYourWebApplicat_11CE0/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="158" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.1BatchCompilationWarmYourWebApplicat_11CE0/image_thumb_2.png" width="271" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;yourIISlogFile.log after the Replace:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.1BatchCompilationWarmYourWebApplicat_11CE0/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="127" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ASP.1BatchCompilationWarmYourWebApplicat_11CE0/image_thumb_3.png" width="584" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Remove the header and save the file with BAT extension&amp;#160; - your Warmer is ready for action. Run it each time you deploy new version.&lt;/p&gt;  &lt;p&gt;Do not forget to remove old temporary files in ASP.NET temporary folder:&lt;/p&gt;  &lt;p&gt;C:\Windows\Microsoft.NET\Framework\&amp;lt;&amp;lt;NET FX VERSION&amp;gt;&amp;gt;\Temporary ASP.NET Files\&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;CAUTION&lt;/em&gt;.&lt;/strong&gt; This action may potentially corrupt your application if you do not provide proper exception handling. On one hand it is good check to make. on other hand – be aware of it and do not do it on production sites unless you are completely sure it will not corrupt the application.&lt;/p&gt;  &lt;h3&gt;Related materials&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2006/04/11/442448.aspx"&gt;Don’t run production ASP.NET Applications with debug=”true” enabled&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/tess/archive/2006/04/13/575364.aspx"&gt;ASP.NET Memory: If your application is in production… then why is debug=true&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/04/21/free-performance-tool-analyze-iis-logs-like-a-pro-with-funnel-web-analyzer.aspx" target="_blank"&gt;Free Performance Tool - Analyze IIS Logs Like A Pro With Funnel Web Analyzer&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;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8758682" 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/Deployment+Phase/default.aspx">Deployment Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category></item><item><title>Security Code Review – String Search Patterns For Finding Input Validation Vulnerabilities</title><link>http://blogs.msdn.com/alikl/archive/2008/07/11/security-code-review-string-search-patterns-for-finding-input-validation-vulnerabilities.aspx</link><pubDate>Fri, 11 Jul 2008 14:24:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8721000</guid><dc:creator>alikl</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8721000.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8721000</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8721000</wfw:comment><description>&lt;p&gt;Well defined set of search patterns helps significantly reduce time (cost) when performing security code inspections. This post focuses on input validation vulnerabilities commonly found in ASP.NET web applications.&lt;/p&gt;  &lt;h3&gt;SQL Injection and Cross Site Scripting (XSS) String search patterns&lt;/h3&gt;  &lt;p&gt;SQL Injections and XSS attacks are most common that exploit improper data access and lack of output encoding. Following are the how-to’s on finding these vulnerabilities:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/03/17/quickly-find-and-fix-cross-site-scripting-xss-vulnerabilities-in-your-asp-net-application.aspx" target="_blank"&gt;Quickly Find And Fix Cross Site Scripting (XSS) Vulnerabilities In Your ASP.NET Application.&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/31/security-code-inspection-eternal-search-for-sql-injection.aspx" target="_blank"&gt;Security Code Inspection - Eternal Search For SQL Injection&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Input Validation vulnerabilities String Search Patterns&lt;/h3&gt;  &lt;p&gt;To search and find security vulnerabilities you start &lt;a href="http://msdn.microsoft.com/en-us/library/ms998375.aspx" target="_blank"&gt;asking questions&lt;/a&gt; or better yet create a list of the questions. Here is the example how - &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;/p&gt;  &lt;p&gt;Use search utility similar to FindStr to perform your searches (look at &lt;a href="http://msdn.microsoft.com/en-us/library/aa302437.aspx#c21618429_004" target="_blank"&gt;Performing Text Searches&lt;/a&gt;). When Visual Studio is available then you can use it - &lt;a href="http://blogs.msdn.com/alikl/archive/2007/06/05/visual-studio-2005-as-general-code-search-tool.aspx" target="_blank"&gt;Visual Studio 2005 As General Code Search Tool&lt;/a&gt;. Any other search tool is just fine. Following are the most common questions and search patterns.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h4&gt;Does the code rely on client-side validation?&lt;/h4&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If the code does not use Validators or Regex there is a potential vulnerability. Review each control how it is validated for type, length, range, string format. In the searches I assume there is no inline code and developers use code behind technique to separate markup from code.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;ASP.NET pages &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;.Validator&amp;quot; *.aspx&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;User Controls&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;.Validator&amp;quot; *.ascx&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Source code&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I &amp;quot;Regex&amp;quot; *.cs&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h4&gt;Is the code susceptible to canonicalization attacks?&lt;/h4&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Review that there is no external input involved in building paths and file names.&lt;/p&gt;  &lt;p&gt;findstr /S /I “File&amp;quot; *.cs&lt;/p&gt;  &lt;p&gt;findstr /S /I “Path&amp;quot; *.cs&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h4&gt;Does the code validate data from all sources? &lt;/h4&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Using Cookies and QueryStrings poses a risk of the tampering threat (review &lt;a href="http://shapingsoftware.com/2008/03/30/stride-explained" target="_blank"&gt;STRIDE Explained&lt;/a&gt; to understand threats). If there is a use of Params property there is a chance for CSRF attack - &lt;a href="http://msdn.microsoft.com/en-us/testing/cc664492.aspx " target="_blank"&gt;Cross-Site Request Forgery Attack explained&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Cookies&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I “Cookies&amp;quot; *.*&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Query Strings&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I “QueryString&amp;quot; *.*&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Params&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;findstr /S /I “Params&amp;quot; *.*&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h4&gt;Does the code use MapPath?&lt;/h4&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If there is a usage of MapPath review that it does not use external input parameters and it is restricted to access only application file space. Make sure its third parameter set to false.&lt;/p&gt;  &lt;p&gt;findstr /S /I “MapPath&amp;quot; *.*&lt;/p&gt;  &lt;h3&gt;How To Mitigate Input And Data Validation Vulnerabilities&lt;/h3&gt;  &lt;p&gt;Below are detailed step-by-step guidelines for writing code that is not vulnerable to SQL Injections and XSS attacks:&lt;/p&gt;  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998274.aspx" target="_blank"&gt;How To: Prevent Cross-Site Scripting in ASP.NET&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb355989.aspx" target="_blank"&gt;How To: Protect From Injection Attacks in ASP.NET&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998271.aspx" target="_blank"&gt;How To: Protect From SQL Injection in ASP.NET&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998267.aspx" target="_blank"&gt;How To: Use Regular Expressions to Constrain Input in ASP.NET&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=EFB9C819-53FF-4F82-BFAF-E11625130C25&amp;amp;displaylang=en" target="_blank"&gt;Microsoft Anti-Cross Site Scripting Library V1.5&lt;/a&gt;&amp;#160; &lt;/li&gt;  &lt;h3&gt;Share Your Practices&lt;/h3&gt;  &lt;p&gt;If you’ve got more search patterns to suggest – please do so! Let’s make the World [Wide Web] a more secure place together.&lt;/p&gt;  &lt;h3&gt;My Related Posts&lt;/h3&gt;  &lt;ul&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/2008/05/25/wcf-security-input-data-validation-sample-visual-studio-project.aspx"&gt;WCF Security - Input/Data Validation Sample Visual Studio Project&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2008/05/25/wcf-security-input-data-validation-using-schemas.aspx"&gt;WCF Security - Input/Data Validation Using Schemas&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8721000" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Input+Validation/default.aspx">Input Validation</category><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/Tools/default.aspx">Tools</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>Performance Sin - Chatty Database Access And Loops (Plus Another Free Performance Tool)</title><link>http://blogs.msdn.com/alikl/archive/2008/04/28/performance-sin-chatty-database-access-and-loops-plus-another-free-performance-tool.aspx</link><pubDate>Mon, 28 Apr 2008 15:31:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8435254</guid><dc:creator>alikl</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8435254.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8435254</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8435254</wfw:comment><description>&lt;p&gt;Chatty database access is the surefire way for slow performance caused by&amp;#160; resources starvation that might&amp;#160; even lead to denial of service. Following is a real world case.&lt;/p&gt;  &lt;h3&gt;Customer &lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/55f71614-ef1b-4015-b9c8-a42c1e700c25.mspx?mfr=true" target="_blank"&gt;Service Unavailable&lt;/a&gt; message is consistently observed when there are more than 150 users access the web site. We think IIS cannot handle more than 150 users. What would you suggest?&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Support&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;Let's see what &amp;quot;Service Unavailable&amp;quot; means. &amp;quot;IIS cannot start any new worker processes because of limited system resources...&amp;quot;. Let's see the code.&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;&lt;strong&gt;The code&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;The code was calling on DB Access function that was put inside &lt;em&gt;for&lt;/em&gt; loop that was called inside event handler. The event handler was called on each GridVew's row creation. Meaning, DB access in nested loop. In case of small GridVew of 10 rows and 10 cells the database would be accessed 100 times for each request. 150 concurrent users would create significant load of 15,000 connections:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ProfilerforMicrosoftSQLServer2005Express_CD84/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="115" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ProfilerforMicrosoftSQLServer2005Express_CD84/image_thumb_1.png" width="496" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;SQL Server Profiler&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;After running SQL Server profiler it became clear that database access should be significantly improved. Following is the number of SQL Commands performed as a result of single request:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ProfilerforMicrosoftSQLServer2005Express_CD84/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="272" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/ProfilerforMicrosoftSQLServer2005Express_CD84/image_thumb.png" width="377" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;For improved performance avoid chatty data base access. Apply caching techniques instead.&lt;/p&gt;  &lt;h3&gt;More free performance tools&lt;/h3&gt;  &lt;p&gt;If you use SQL Server 2005 Express which does not come with built-in profiler you might find useful the following free tool:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlprofiler.googlepages.com/" target="_blank"&gt;Profiler for Microsoft SQL Server 2005 Express Edition&lt;/a&gt;&lt;/p&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/04/21/iis7-admin-pack-offers-built-in-performance-analysis-reports.aspx" target="_blank"&gt;IIS7 Admin Pack Offers Built In Performance Analysis Reports&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" target="_blank"&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/2008/04/21/free-performance-tool-analyze-iis-logs-like-a-pro-with-funnel-web-analyzer.aspx"&gt;Free Performance Tool - Analyze IIS Logs Like A Pro With Funnel Web Analyzer&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/2007/03/28/performance-testing-for-the-masses.aspx"&gt;Performance Testing For The Masses&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;&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8435254" 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/Deployment+Phase/default.aspx">Deployment Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category></item><item><title>Free Performance Tool - Analyze IIS Logs Like A Pro With Funnel Web Analyzer</title><link>http://blogs.msdn.com/alikl/archive/2008/04/21/free-performance-tool-analyze-iis-logs-like-a-pro-with-funnel-web-analyzer.aspx</link><pubDate>Mon, 21 Apr 2008 13:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8414362</guid><dc:creator>alikl</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8414362.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8414362</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8414362</wfw:comment><description>&lt;P&gt;These free performance tools will save you time and money identifying performance bottlenecks. Your customers will thank you for building fast and responsive applications.&lt;/P&gt;
&lt;H3&gt;Funnel Web Analyzer 5.0 for Windows&lt;/H3&gt;
&lt;P&gt;Download the tool &lt;A href="http://www.quest.com/funnel-web-analyzer/software-downloads.asp" target=_blank mce_href="http://www.quest.com/funnel-web-analyzer/software-downloads.asp"&gt;here.&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Analyzer gives insight into everything from server load and customer usage to intranet analysis. It allows you to gain vital feedback on visitor behaviour and preferences, so you can more accurately customize your site to meet the needs of your clients&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;H3&gt;How- to use&lt;/H3&gt;
&lt;P&gt;After you download and install the tool &lt;!--more--&gt;- run it. Just drag and drop log files onto it and then click on View icon:&lt;/P&gt;
&lt;P&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=210 alt=image src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/FreeToolsFunnelsqlexpressprofiler_7ED0/image_3.png" width=466 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/FreeToolsFunnelsqlexpressprofiler_7ED0/image_3.png"&gt; &lt;/P&gt;
&lt;P&gt;You will be presented with nice array of summary and detailed reports:&lt;/P&gt;
&lt;P&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=158 alt=image src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/FreeToolsFunnelsqlexpressprofiler_7ED0/image_6.png" width=466 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/FreeToolsFunnelsqlexpressprofiler_7ED0/image_6.png"&gt; &lt;/P&gt;
&lt;H3&gt;Usage Scenarios&lt;/H3&gt;
&lt;P&gt;There are few scenarios I can see this tool would be very useful:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Developer analyzes the module she developed during development phase just before submitting for holistic performance testing. &lt;/LI&gt;
&lt;LI&gt;IT support personnel probes production applications to get a quick view on potential performance hotspots. &lt;/LI&gt;
&lt;LI&gt;Performance team analyzes the data after running load/stress tests. &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/alikl/archive/2007/11/02/identify-asp-net-web-services-and-wcf-performance-issues-by-examining-iis-logs.aspx" mce_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/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;LI&gt;&lt;A href="http://blogs.msdn.com/ace_team/archive/2008/03/11/improve-net-applications-performance-effectively-and-efficiently.aspx" target=_blank mce_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/03/28/performance-testing-for-the-masses.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/03/28/performance-testing-for-the-masses.aspx"&gt;Performance Testing For The Masses&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;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8414362" 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/Performance/default.aspx">Performance</category></item><item><title>Quickly Find And Fix Cross Site Scripting (XSS) Vulnerabilities In Your ASP.NET Application.</title><link>http://blogs.msdn.com/alikl/archive/2008/03/17/quickly-find-and-fix-cross-site-scripting-xss-vulnerabilities-in-your-asp-net-application.aspx</link><pubDate>Mon, 17 Mar 2008 15:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8289686</guid><dc:creator>alikl</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8289686.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8289686</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8289686</wfw:comment><description>&lt;P&gt;Want to quickly check your ASP.NET Web application for &lt;A href="http://en.wikipedia.org/wiki/Cross-site_scripting" target=_blank mce_href="http://en.wikipedia.org/wiki/Cross-site_scripting"&gt;Cross Site Scripting (XSS) vulnerability&lt;/A&gt;?&lt;/P&gt;
&lt;P&gt;It is pretty easy with the knowledge and tools you already have. This post describes how to quickly find and fix most of XSS vulnerabilities in your code.&lt;/P&gt;
&lt;H3&gt;Why XSS vulnerabilities are possible&lt;/H3&gt;
&lt;P&gt;XSS vulnerabilities are possible when un-sanitized data printed out on the page. From what I witness when I do security code inspections most cases can be summarized to two most common:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Using &lt;SPAN style="COLOR: #2b91af"&gt;DataBinder&lt;/SPAN&gt;.Eval function: &lt;/LI&gt;&lt;/UL&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: #2b91af"&gt;DataBinder&lt;/SPAN&gt;.Eval(Container.DataItem, &lt;SPAN style="COLOR: #a31515"&gt;"TEXT"&lt;/SPAN&gt;) &lt;SPAN style="BACKGROUND: #ffee62"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;LI&gt;Assigning to Text property of the control: &lt;/LI&gt;&lt;/UL&gt;&lt;PRE class=code&gt;Label1.Text = TextBox1.Text;&lt;/PRE&gt;&lt;PRE class=code&gt;&lt;UL&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;EM&gt;[Update 20.7.08] &lt;/EM&gt;&lt;/STRONG&gt;Assigning to Text property of the control: &lt;/LI&gt;&lt;/UL&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;SPAN style="BACKGROUND: #ffee62"&gt;&amp;lt;%&lt;/SPAN&gt;=myStringGoesHere...&lt;/P&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;UL&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;/UL&gt;
&lt;H3&gt;How to quickly find XSS vulnerabilities&lt;/H3&gt;
&lt;P&gt;Above patterns are easily identifiable using any strings search utility. I use &lt;A href="http://blogs.msdn.com/alikl/archive/2007/06/05/visual-studio-2005-as-general-code-search-tool.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/06/05/visual-studio-2005-as-general-code-search-tool.aspx"&gt;Visual Studio 2005 As General Code Search Tool&lt;/A&gt; to find such vulnerabilities. When Visual Studio is not an option, just use FindStr, here is an example - &lt;A href="http://blogs.msdn.com/alikl/archive/2007/03/20/code-inspection-first-look-for-what-to-look-for.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/03/20/code-inspection-first-look-for-what-to-look-for.aspx"&gt;Code Inspection - First Look For What To Look For&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Run your search for ".Eval(" and then for ".Text =". You might want to modify slightly it as some folks omit space before "=" or other minor changes. &lt;/P&gt;
&lt;P&gt;Use searches similar to these:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;findstr /S /I ".Text =" *.cs &lt;/LI&gt;
&lt;LI&gt;findstr /S /I ".Eval(" *.aspx &lt;/LI&gt;
&lt;LI&gt;findstr /S /I ".Eval(" *.ascx&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;EM&gt;[Update 20.7.08]&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;findstr /S /I "&amp;lt;%=" *.aspx&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Ran your search yet? What do you see? Scared?&lt;/P&gt;
&lt;H3&gt;How to quickly fix XSS vulnerabilities&lt;/H3&gt;
&lt;P&gt;The fix is pretty simple - just apply Html Encoding to both cases. The best is using freely available &lt;A href="http://www.microsoft.com/info.aspx?na=47&amp;amp;p=1&amp;amp;SrcDisplayLang=en&amp;amp;SrcCategoryId=&amp;amp;SrcFamilyId=9a2b9c92-7ad9-496c-9a89-af08de2e5982&amp;amp;u=details.aspx%3ffamilyid%3dEFB9C819-53FF-4F82-BFAF-E11625130C25%26displaylang%3den" target=_blank mce_href="http://www.microsoft.com/info.aspx?na=47&amp;amp;p=1&amp;amp;SrcDisplayLang=en&amp;amp;SrcCategoryId=&amp;amp;SrcFamilyId=9a2b9c92-7ad9-496c-9a89-af08de2e5982&amp;amp;u=details.aspx%3ffamilyid%3dEFB9C819-53FF-4F82-BFAF-E11625130C25%26displaylang%3den"&gt;Microsoft Anti-Cross Site Scripting Library V1.5&lt;/A&gt;. Note that ASP.NET’s Server.HtmlEncode is not the safest one as it only encodes &amp;lt;,&amp;gt;,",&amp;amp; characters which is not sufficient to protect against all possible attacks.&lt;/P&gt;
&lt;H3&gt;My related posts&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2008/01/24/security-code-review-use-visual-studio-bookmarks-to-capture-security-findings.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2008/01/24/security-code-review-use-visual-studio-bookmarks-to-capture-security-findings.aspx"&gt;Security Code Review – Use Visual Studio Bookmarks To Capture Security Findings&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2007/03/31/security-code-inspection-eternal-search-for-sql-injection.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/03/31/security-code-inspection-eternal-search-for-sql-injection.aspx"&gt;Security Code Inspection - Eternal Search For SQL Injection&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2007/11/21/asp-net-2-0-internet-security-reference-implementation-have-it-handy.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/11/21/asp-net-2-0-internet-security-reference-implementation-have-it-handy.aspx"&gt;ASP.NET 2.0 Internet Security Reference Implementation - Have It Handy&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8289686" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Input+Validation/default.aspx">Input Validation</category><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/Tools/default.aspx">Tools</category></item><item><title>Stress Test ASP.NET Web Application With Free WCAT Tool</title><link>http://blogs.msdn.com/alikl/archive/2008/03/09/stress-test-asp-net-web-application-with-free-wcat-tool.aspx</link><pubDate>Sun, 09 Mar 2008 10:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8116606</guid><dc:creator>alikl</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/alikl/comments/8116606.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=8116606</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=8116606</wfw:comment><description>&lt;P&gt;Building ASP.NET web applications? Plan to serve thousands of users? Would you like to see how your application would behave [misbehave] under stress?&lt;/P&gt;
&lt;P&gt;Use simple-to-use and freely available WCAT tool to generate the load and get detailed report for expected throughput (requests/sec) and other important performance-wise information.&lt;/P&gt;
&lt;H3&gt;Summary of steps&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Install WCAT&lt;/STRONG&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Create configuration files&lt;/STRONG&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Run the test&lt;/STRONG&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Examine results&lt;/STRONG&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Next section describes each step in details. &lt;STRONG&gt;Note&lt;/STRONG&gt;, this post is a how-to, a jump start - not the guidelines or best practices of how to use the tool.&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Install WCAT&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;Download and install &lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=56FC92EE-A71A-4C73-B628-ADE629C89499&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=56FC92EE-A71A-4C73-B628-ADE629C89499&amp;amp;displaylang=en"&gt;Internet Information Services (IIS) 6.0 Resource Kit Tools&lt;/A&gt;. For the purpose of our exercise there is no need to install all the tools included with the resources kit, only WCAT.&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Create configuration files&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;There are three textual files one needs to create and configure (you can give any name and extension of your choice):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;script.txt&lt;/STRONG&gt; - this file defines the requests, in other words what pages to request and how to request it. Following is an example of simple script.txt file: &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;NEW TRANSACTION &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; classId = 1 &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NEW REQUEST HTTP &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Verb = "GET" &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; URL = "http://localhost/BankingShmanking/Default.aspx"&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;distribution.txt&lt;/STRONG&gt; - defines weights among different requests. For example, if I need to generate request to page1.aspx twice as to page2.aspx, I will define it in this file. In case of loading only one page, the file is meaningless. Following is an example of simple distribution.txt file (1 refers to classId in script.txt file, and 50 is that 50% of the load should got this file which is meaningless since there is only one page to request, thus it will get the whole 100% load): &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;1 50&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;config.txt &lt;/STRONG&gt;- determines the duration of the test, number of clients that will generate the requests against the web application. Following is the example of simple config.txt file: &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Warmuptime 5s &lt;BR&gt;Duration 30s &lt;BR&gt;CooldownTime 5s &lt;BR&gt;NumClientMachines 1 &lt;BR&gt;NumClientThreads 20&lt;/P&gt;
&lt;P&gt;Save the files in "C:\Program Files\IIS Resources\WCAT Controller" folder.&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Run the test&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;To run the stress test open command prompt by opening Run window(Windows + R) type cmd and hit Enter. Change current directory to "C:\Program Files\IIS Resources\WCAT Controller&amp;gt;" and run the following command to test the page hosted on the localhost:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;wcctl -c config.txt -d distribution.txt -s script.txt -a localhost&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;then open second command prompt, change current folder to "C:\Program Files\IIS Resources\WCAT Client" and run the following command to actually launch the virtual client's requests from local machine:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;wcclient.exe localhost&lt;/EM&gt;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Examine results&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;The results are displayed interactively in the command line windows&lt;/P&gt;&lt;BR&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/StressASP.NETApplicationWithFreeWCATTool_7CE7/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/StressASP.NETApplicationWithFreeWCATTool_7CE7/image_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=383 alt=image src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/StressASP.NETApplicationWithFreeWCATTool_7CE7/image_thumb.png" width=638 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/StressASP.NETApplicationWithFreeWCATTool_7CE7/image_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The tool also generates log file that includes logged metrics - look for it in "C:\Program Files\IIS Resources\WCAT Controller" folder.&lt;/P&gt;
&lt;P&gt;WCAT tool is actively developed by IIS team and recently they released new version of the tool - WCAT 6.3, download it from &lt;A href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1466" target=_blank mce_href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1466"&gt;here&lt;/A&gt;, free.&lt;/P&gt;
&lt;H3&gt;Related materials&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;This post was mainly based on this article - &lt;A href="http://learn.iis.net/page.aspx/154/iis-7-output-caching/" target=_blank mce_href="http://learn.iis.net/page.aspx/154/iis-7-output-caching/"&gt;IIS 7.0 Output Caching&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.iis.net/chrisad/archive/2006/07/19/WCAT_3A00_--Easy_2C00_-Magical_2C00_-Stress-Testing-for-IIS-Web-Applications.aspx" target=_blank mce_href="http://blogs.iis.net/chrisad/archive/2006/07/19/WCAT_3A00_--Easy_2C00_-Magical_2C00_-Stress-Testing-for-IIS-Web-Applications.aspx"&gt;WCAT: Easy, Magical, Stress Testing for IIS Web Applications&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1466" target=_blank mce_href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1466"&gt;WCat 6.3 (x86)&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/alikl/archive/2007/03/28/performance-testing-for-the-masses.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/03/28/performance-testing-for-the-masses.aspx"&gt;Performance Testing For The Masses&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" mce_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 – Revised&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" mce_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/29/patterns-practices-performance-testing-guidance-for-web-applications-final-cut.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/08/29/patterns-practices-performance-testing-guidance-for-web-applications-final-cut.aspx"&gt;patterns &amp;amp; practices Performance Testing Guidance for Web Applications - Final Cut&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" mce_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;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2007/06/20/performance-testing-objectives-document-template.aspx" mce_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;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8116606" 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/Performance/default.aspx">Performance</category></item><item><title>Performance Sin - Using Exceptions To Control Flow</title><link>http://blogs.msdn.com/alikl/archive/2008/02/02/performance-sin-using-exceptions-to-control-flow.aspx</link><pubDate>Sat, 02 Feb 2008 16:19:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7390784</guid><dc:creator>alikl</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/alikl/comments/7390784.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=7390784</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=7390784</wfw:comment><description>&lt;p&gt;Want to spot coding anti-patterns from performance perspective without actually looking in the code?&lt;/p&gt;  &lt;p&gt;One of the common performance coding anti-patterns I&amp;#8217;ve noticed lately is using Exception Handling to control program flow. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;The anti-patterns&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Most common anti-pattern is just using exception handling to control flow, in some cases it was even nested exception handling &amp;#8211; that means the exception is thrown anyway.&lt;/p&gt;  &lt;p&gt;In other cases there were empty &amp;#8220;catch&amp;#8221; exception statements. That means that precious cycles .Net consumes to handle the exception spent for nothing.&lt;/p&gt;  &lt;p&gt;The last case was where exception handling was done to catch simple types parsing. That was done on each request. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;How to identify Exception Handling anti-pattern&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;To identify exception handling anti-pattern set &amp;#8220;.NET CLR Exceptions/# of Excepts Thrown&amp;#8221; perf counter. If you see the graph constantly climbs on each request chance are Exception Handling is used to control the flow which is performance anti-pattern:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceSinUsingExceptionsToControlFl_D5AC/clip_image002_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="126" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceSinUsingExceptionsToControlFl_D5AC/clip_image002_thumb.jpg" width="221" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Look at the relevant source code to spot try/catch blocks. If the source code is not available use &lt;a href="http://www.aisto.com/roeder/dotnet/" target="_blank"&gt;Reflector&lt;/a&gt; to reverse engineer the compiled assemblies into C# sources &amp;#8211; I used it very successfully during my latest performance review.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Best practices&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Do not use exception handling to control the flow. Try to reduce catching exceptions to only most upper component/class. Catching exceptions is expensive from both CPU and memory perspective. &lt;/p&gt;  &lt;p&gt;Use TryParse method instead Parse method to avoid throwing exceptions .&lt;/p&gt;  &lt;p&gt;Use simple &amp;quot;if&amp;quot; statement to check for nulls.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Tools&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Use perfmon to spot the anti-pattern with Exception handling. Run perfmon in command line and add &amp;#8220;.NET CLR Exceptions/# of Excepts Thrown&amp;#8221; counter. Then run few scenarios to see the graph. &lt;/p&gt;  &lt;p&gt;Use Practice Checker for static code analysis. The tool scans the code and reveals excessive usage of exception handling.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;My related posts&lt;/b&gt;&lt;/p&gt;  &lt;ul&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 &amp;#8211; Practices Checker&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7390784" 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/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/Exception+Handling/default.aspx">Exception Handling</category></item></channel></rss>