<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>.NET</title>
        <link>http://geekswithblogs.net/joycsharp/category/5032.aspx</link>
        <description>.NET BCL, ASP.NET, Winform object model, technology analysis. Some of the post may overlap with Implementation, Architecture catagory.</description>
        <language>en-US</language>
        <copyright>Mohammad Ashraful Alam</copyright>
        <managingEditor>joy_csharp@yahoo.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>nAML: A New Revolutionary Way to Model Your .NET Applications!</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2008/09/12/naml-a-new-revolutionary-way-to-model-your-.net-applications.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/ashraful/WindowsLiveWriter/nAMLANewRevolutionaryWay.NETApplications_11FDE/naml.jpg"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="244" alt="naml" width="197" border="0" src="http://weblogs.asp.net/blogs/ashraful/WindowsLiveWriter/nAMLANewRevolutionaryWay.NETApplications_11FDE/naml_thumb.jpg" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Understanding the architecture and code in software application plays as major factors while building good software products. Having an easy to understand visual notation, not only helps architects to model the system efficiently, but also helps developers to quickly implement that, as well as it helps the re-engineering process to easily adopt the architectural model with respect to new requirement. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;A new visual modeling technique, termed as “nAML” (.NET Application Modeling Language) is being introduced which overcomes the limitation of typical modeling languages by providing revolutionary way within a single space to describe an application system with its structural and behavioral, as well as physical and logical components. It illustrates real world samples, from user interface experience, .NET specific language (such as C#) classes to database level SQL commands, to let software architects and developers to have a clean model for the future system. One of it’s the most powerful objectives of this new visual language is the besides an easy way to model the system, the target model will require near to zero knowledge on notation semantics from reader aspect.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Primary Objectives&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;The primary objectives of nAML can be considered as follows:&lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;
    &lt;p&gt;&lt;font size="2"&gt;Provides a single space to visually describe one or more application systems with structural and behavioral components.&lt;/font&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;&lt;font size="2"&gt;Provides a single space to visually describe one or more application systems with logical and physical components.&lt;/font&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;&lt;font size="2"&gt;Provides a single space to visually describe one or more application systems from top to low level.&lt;/font&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;&lt;font size="2"&gt;Provides a single space to visually describe a part or whole of one or more application systems.&lt;/font&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;&lt;font size="2"&gt;Extremely simple and easy understand and learn from readers and designers perspective.&lt;/font&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;&lt;font size="2"&gt;Concentrates on .NET applications, with its related logical and physical entities (user interface, application logic, business logic, database etc).&lt;/font&gt;&lt;/p&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Links and Downloads&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Here is the nAML project site: &lt;/font&gt;&lt;a href="http://code.msdn.microsoft.com/nAML"&gt;&lt;font size="2"&gt;http://code.msdn.microsoft.com/nAML&lt;/font&gt;&lt;/a&gt; &lt;br /&gt;
&lt;font size="2"&gt;Download the latest specification, examples and Visio 2003 Stencil for nAML tutorial from &lt;/font&gt;&lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=naml&amp;amp;DownloadId=3083"&gt;&lt;font size="2"&gt;here&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;. &lt;br /&gt;
Download Visio 2003 Stencil for nAML from &lt;/font&gt;&lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=naml&amp;amp;DownloadId=3084"&gt;&lt;font size="2"&gt;here&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:89abd563-5f7b-41c1-9c15-69d22a4c2289" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/architecture"&gt;architecture&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/modeling"&gt;modeling&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/.net"&gt;.net&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/asp.net"&gt;asp.net&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/development"&gt;development&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125132"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125132" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/joycsharp/aggbug/125132.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Ashraful Alam</dc:creator>
            <guid>http://geekswithblogs.net/joycsharp/archive/2008/09/12/naml-a-new-revolutionary-way-to-model-your-.net-applications.aspx</guid>
            <pubDate>Fri, 12 Sep 2008 15:35:10 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/joycsharp/comments/125132.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/joycsharp/archive/2008/09/12/naml-a-new-revolutionary-way-to-model-your-.net-applications.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/joycsharp/comments/commentRss/125132.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/joycsharp/services/trackbacks/125132.aspx</trackback:ping>
        </item>
        <item>
            <title>Using .NET 2.0 Generics for Custom Entity Collection</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2008/02/18/using-.net-2.0-generics-for-custom-entity-collection.aspx</link>
            <description>&lt;p&gt;&lt;font face="ver" size="2"&gt;Generics is a new feature in .NET 2.0 which allows us to create a data structure without committing to a specific data type. In the early age of .net 2.0 (i.e. .net 1.x), while using custom entity model in our application data architecture, we had to create a separate class regarding the collection for each of custom entity. &lt;/font&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;strong&gt;&lt;font face="ver" size="2"&gt;The custom entity&lt;/font&gt;&lt;/strong&gt;&lt;/pre&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;&lt;font face="ver" size="2"&gt;public class &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: teal"&gt;SystemUser
&lt;/span&gt;{
    &lt;span style="COLOR: blue"&gt;public string &lt;/span&gt;_Name, _Password;

    &lt;span style="COLOR: blue"&gt;public &lt;/span&gt;SystemUser(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;name, &lt;span style="COLOR: blue"&gt;string &lt;/span&gt;password)
    {
        _Name = name;
        _Password = password;
    }

    &lt;span style="COLOR: blue"&gt;public string &lt;/span&gt;Password
    {
        &lt;span style="COLOR: blue"&gt;get &lt;/span&gt;{ &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;_Password; }
        &lt;span style="COLOR: blue"&gt;set &lt;/span&gt;{ _Password = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;; }
    }

    &lt;span style="COLOR: blue"&gt;public string &lt;/span&gt;Name
    {
        &lt;span style="COLOR: blue"&gt;get &lt;/span&gt;{ &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;_Name; }
        &lt;span style="COLOR: blue"&gt;set &lt;/span&gt;{ _Name = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;; }
    }&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="ver" size="2"&gt;The old age custom entity collection class&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;For a custom entity "SystemUser" we had to create a separate collection class as below:&lt;/font&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;public class &lt;/span&gt;&lt;span style="COLOR: teal"&gt;SystemUserCollection&lt;/span&gt;: &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: teal"&gt;CollectionBase
&lt;/span&gt;{
    &lt;span style="COLOR: blue"&gt;public &lt;/span&gt;&lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;[ &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;index ]
    {
        &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;{&lt;span style="COLOR: blue"&gt;return &lt;/span&gt;( (&lt;span style="COLOR: teal"&gt;SystemUser&lt;/span&gt;) List[index]);}
        &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;{List[index]=&lt;span style="COLOR: blue"&gt;value&lt;/span&gt;;}
    }
    
    &lt;span style="COLOR: blue"&gt;public int &lt;/span&gt;Add(&lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;value)
    {
        &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;(List.Add(value));
    }
    
    &lt;span style="COLOR: blue"&gt;public int &lt;/span&gt;IndexOf(&lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;value)
    {
        &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;(List.IndexOf(value));
    }
    
    &lt;span style="COLOR: blue"&gt;public void &lt;/span&gt;Insert(&lt;span style="COLOR: blue"&gt;int &lt;/span&gt;index, &lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;value)
    {
        List.Insert(index, value);
    }
    
    &lt;span style="COLOR: blue"&gt;public void &lt;/span&gt;Remove(&lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;value)
    {
        List.Remove(value);    
    }
    
    &lt;span style="COLOR: blue"&gt;public bool &lt;/span&gt;Contains(&lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;value)
    {
        &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;(List.Contains(value));    
    }
  
}
&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;pre class="code"&gt;&lt;strong&gt;&lt;font face="ver" size="2"&gt;Custom entity collection using .net 2.0 generics&lt;/font&gt;&lt;/strong&gt;&lt;/pre&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;The generics in .net 2.0 made developers life extremely easy, we can create a common collection class for all custom business entity with respect to common collection based functionality.&lt;/font&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: gray"&gt;&lt;font face="ver" size="2"&gt;/// &amp;lt;summary&amp;gt;
/// &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: green"&gt;This is the helper collection class, that holds &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: green"&gt;generic type data.
&lt;/span&gt;&lt;span style="COLOR: gray"&gt;/// &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: green"&gt;&lt;font face="ver" size="2"&gt;This type will be used to manipulate generic class.
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: gray"&gt;/// &amp;lt;/summary&amp;gt;
/// &amp;lt;typeparam name="GenericType"&amp;gt;&amp;lt;/typeparam&amp;gt;
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;public class &lt;/span&gt;&lt;span style="COLOR: teal"&gt;CustomCollection&lt;/span&gt;&amp;lt;GenericType&amp;gt; : &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: teal"&gt;CollectionBase
&lt;/span&gt;{
        &lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: gray"&gt;&lt;font face="ver" size="2"&gt;/// &amp;lt;summary&amp;gt;
        /// &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;&lt;font face="ver" size="2"&gt;Adds an object to the collection.
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: gray"&gt;/// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="GenericObject"&amp;gt;&amp;lt;/param&amp;gt;
        &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public void &lt;/span&gt;Add(GenericType item)
        {
            InnerList.Add(item);
        }

        &lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: gray"&gt;&lt;font face="ver" size="2"&gt;/// &amp;lt;summary&amp;gt;
        /// &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;&lt;font face="ver" size="2"&gt;Removes an object from the collection.
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: gray"&gt;/// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="index"&amp;gt;&amp;lt;/param&amp;gt;
        &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public void &lt;/span&gt;Remove(&lt;span style="COLOR: blue"&gt;int &lt;/span&gt;index)
        {
            InnerList.RemoveAt(index);
        }

        &lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: gray"&gt;&lt;font face="ver" size="2"&gt;/// &amp;lt;summary&amp;gt;
        /// &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;&lt;font face="ver" size="2"&gt;Gets and sets the appropriate object &lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: green"&gt;&lt;font face="ver" size="2"&gt;in the specified index.
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: gray"&gt;/// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="index"&amp;gt;&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
        &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;GenericType &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;[&lt;span style="COLOR: blue"&gt;int &lt;/span&gt;index]
        {
            &lt;span style="COLOR: blue"&gt;get &lt;/span&gt;{ &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;((GenericType)List[index]); }
            &lt;span style="COLOR: blue"&gt;set &lt;/span&gt;{ List[index] = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;; }
        }

}&lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: green"&gt;&lt;font face="ver" size="2"&gt;//end of GenericCollection&amp;lt;GenericType&amp;gt;
&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="ver" size="2"&gt;Using generic collection&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;Generic collection classes can be used in the following way:&lt;/font&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;public static &lt;/span&gt;&lt;span style="COLOR: teal"&gt;CustomCollection&lt;/span&gt;&amp;lt;&lt;span style="COLOR: teal"&gt;SystemUser&lt;/span&gt;&amp;gt; &lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;GetSampleGenericCollection()
{
    &lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;user1 = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: teal"&gt;SystemUser&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"ashraf"&lt;/span&gt;, &lt;span style="COLOR: maroon"&gt;"12345"&lt;/span&gt;);
    &lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;user2 = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: teal"&gt;SystemUser&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"ehsan"&lt;/span&gt;, &lt;span style="COLOR: maroon"&gt;"12345"&lt;/span&gt;);
    &lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;user3 = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: teal"&gt;SystemUser&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"tuhin"&lt;/span&gt;, &lt;span style="COLOR: maroon"&gt;"12345"&lt;/span&gt;);
    &lt;span style="COLOR: teal"&gt;SystemUser &lt;/span&gt;user4 = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: teal"&gt;SystemUser&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"rabbi"&lt;/span&gt;, &lt;span style="COLOR: maroon"&gt;"12345"&lt;/span&gt;);

    &lt;span style="COLOR: teal"&gt;CustomCollection&lt;/span&gt;&amp;lt;&lt;span style="COLOR: teal"&gt;SystemUser&lt;/span&gt;&amp;gt; mySystemUserCollection &lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;= &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: teal"&gt;CustomCollection&lt;/span&gt;&amp;lt;&lt;span style="COLOR: teal"&gt;SystemUser&lt;/span&gt;&amp;gt;();

    mySystemUserCollection.Add(user1);
    mySystemUserCollection.Add(user2);
    mySystemUserCollection.Add(user3);
    mySystemUserCollection.Add(user4);

    &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;mySystemUserCollection;

}&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;Download code: &lt;/font&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-907464dabda55b30.skydrive.live.com/embedrowdetail.aspx/Community/generic-collection.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b3888ebd-2dc6-4ab7-9df9-fa4e5a6c445c" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/.net"&gt;.net&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/coding"&gt;coding&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/programming"&gt;programming&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/C#"&gt;C#&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/sample"&gt;sample&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=119719"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=119719" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/joycsharp/aggbug/119719.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Ashraful Alam</dc:creator>
            <guid>http://geekswithblogs.net/joycsharp/archive/2008/02/18/using-.net-2.0-generics-for-custom-entity-collection.aspx</guid>
            <pubDate>Mon, 18 Feb 2008 11:12:59 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/joycsharp/comments/119719.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/joycsharp/archive/2008/02/18/using-.net-2.0-generics-for-custom-entity-collection.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/joycsharp/comments/commentRss/119719.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/joycsharp/services/trackbacks/119719.aspx</trackback:ping>
        </item>
        <item>
            <title>ASP.NET Role Based Security: The Basics</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2008/02/18/asp.net-role-based-security-the-basics.aspx</link>
            <description>&lt;p align="justify"&gt;&lt;font face="ver" size="2"&gt;Authentication and authorization is the two basic part of the user-end security in asp.net web applications. After to successful authentication of a user, authorization takes the place according to which the authenticated user are allowed to access to the corresponding resources in the web application.&lt;/font&gt;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;font face="ver" size="2"&gt;Role based security is very basic requirements in the current trend of web applications. Mostly there are two roles involved, which are registered user and the admin users. However in a web application a user can have multiple roles which can be authorized on page and page control level. Today we'll check a basic sample which includes page based authorizations for specific roles.&lt;/font&gt;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;font face="ver" size="2"&gt;To implement the basic role based security, there are three points to be considered. In this example we are considering two different roles "member" and "admin". There are two separate folders named "member", which can be accessed by any logged in user, including admin users and "admin", where only the user who contains the "admin" role can access the child resources (page, images etc).&lt;/font&gt;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;strong&gt;&lt;font face="ver" size="2"&gt;1. Defining the authorization regions in web.config&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;font face="ver" size="2"&gt;The following xml tags are required to be added under the "configuration" node of the web.config.&lt;/font&gt;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;font face="ver" size="2"&gt;Defining security authorization for "member" users&lt;/font&gt;&lt;/p&gt;
&lt;div align="justify"&gt;
&lt;pre class="code"&gt;&lt;font face="ver" size="2"&gt;  &lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;location &lt;/span&gt;&lt;span style="COLOR: red"&gt;path&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;member&lt;/span&gt;"&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;system.web&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;authorization&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;deny &lt;/span&gt;&lt;span style="COLOR: red"&gt;users&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;?&lt;/span&gt;"&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;authorization&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;system.web&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;location&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;font face="ver" size="2"&gt;&amp;gt;
&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p align="justify"&gt;&lt;font face="ver" size="2"&gt;Defining security authorization for "admin" users&lt;/font&gt;&lt;/p&gt;
&lt;div align="justify"&gt;
&lt;pre class="code"&gt;&lt;font face="ver" size="2"&gt;  &lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;location &lt;/span&gt;&lt;span style="COLOR: red"&gt;path&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;admin&lt;/span&gt;"&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;system.web&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;authorization&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;allow &lt;/span&gt;&lt;span style="COLOR: red"&gt;roles&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;admin&lt;/span&gt;"&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;deny &lt;/span&gt;&lt;span style="COLOR: red"&gt;users&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;*&lt;/span&gt;"&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;authorization&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;system.web&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;location&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;font face="ver" size="2"&gt;&amp;gt;
&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p align="justify"&gt;&lt;strong&gt;&lt;font face="ver" size="2"&gt;2. Authenticating the user&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;font face="ver" size="2"&gt;After the successful authentication, the following codes are required to establish the form based authentication for the corresponding user.&lt;/font&gt;&lt;/p&gt;
&lt;div align="justify"&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: green"&gt;//Authenticating the user Identity. &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div align="justify"&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;System.Web.Security.&lt;span style="COLOR: teal"&gt;FormsAuthentication&lt;/span&gt;.RedirectFromLoginPage&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div align="justify"&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;(&lt;span style="COLOR: maroon"&gt;"member1"&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.CheckBox1.Checked);&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p align="justify"&gt;&lt;strong&gt;&lt;font face="ver" size="2"&gt;3. Implementing the role based security&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;font face="ver" size="2"&gt;The "Application_AuthenticateRequest" event which was defined in the "Global.asax" file, will include the appropriate codes regarding the role info of the logged in user, which will be accesses each time for any web request in this web application. This can be done in either "cache" or "cookie" mechanism.&lt;/font&gt;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;u&gt;Cache based mechanism&lt;/u&gt;&lt;/p&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;    &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Application_AuthenticateRequest(&lt;span style="COLOR: teal"&gt;Object&lt;/span&gt; sender, &lt;span style="COLOR: teal"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;    {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;        &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;            &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User.Identity.IsAuthenticated)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User.Identity.AuthenticationType != &lt;span style="COLOR: maroon"&gt;"Forms"&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Exception&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"Only forms authentication is supported, not "&lt;/span&gt; +&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        &lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User.Identity.AuthenticationType);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                System.Security.Principal.&lt;span style="COLOR: teal"&gt;IIdentity&lt;/span&gt; userId = &lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User.Identity;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: green"&gt;//if role info is already NOT loaded into cache, put the role info in cache&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (System.Web.&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.Cache[userId.Name] == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[] roles;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (userId.Name == &lt;span style="COLOR: maroon"&gt;"admin1"&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        roles = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[1] { &lt;span style="COLOR: maroon"&gt;"admin"&lt;/span&gt; };&lt;span style="COLOR: green"&gt;//this info will be generally collected from database&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (userId.Name == &lt;span style="COLOR: maroon"&gt;"member1"&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        roles = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[1] { &lt;span style="COLOR: maroon"&gt;"member"&lt;/span&gt; };&lt;span style="COLOR: green"&gt;//this info will be generally collected from database&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        roles = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[1] { &lt;span style="COLOR: maroon"&gt;"public"&lt;/span&gt; };&lt;span style="COLOR: green"&gt;//this info will be generally collected from database                   &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: green"&gt;//1 hour sliding expiring time. Adding the roles in chache. This will be used in Application_AuthenticateRequest event located in Global.ascx.cs file to attach user Principal object.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    System.Web.&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.Cache.Add(userId.Name, roles, &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.MaxValue, &lt;span style="COLOR: teal"&gt;TimeSpan&lt;/span&gt;.FromHours(1), System.Web.Caching.&lt;span style="COLOR: teal"&gt;CacheItemPriority&lt;/span&gt;.BelowNormal, &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: green"&gt;//now assign the user role in the current security context&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; System.Security.Principal.&lt;span style="COLOR: teal"&gt;GenericPrincipal&lt;/span&gt;(userId, (&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[])System.Web.&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.Cache[userId.Name]);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;    }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;u&gt;Cookie based mechanism&lt;/u&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; 
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;    &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Application_AuthenticateRequest(&lt;span style="COLOR: teal"&gt;Object&lt;/span&gt; sender, &lt;span style="COLOR: teal"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;    {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;        &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;            &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (Request.IsAuthenticated == &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User.Identity.AuthenticationType != &lt;span style="COLOR: maroon"&gt;"Forms"&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Exception&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"Only forms authentication is supported, not "&lt;/span&gt; +&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        &lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User.Identity.AuthenticationType);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: green"&gt;//Create/Retrieve cookie and initizalyze the role info in the current security context&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; userInformation = &lt;span style="COLOR: teal"&gt;String&lt;/span&gt;.Empty;&lt;span style="COLOR: green"&gt;//where the cookie info will be placed&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[] roles;&lt;span style="COLOR: green"&gt;//where the user role will be placed&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: green"&gt;// Create the roles cookie if it doesn't exist yet for this session.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; ((Request.Cookies[&lt;span style="COLOR: maroon"&gt;"cnstUserRole"&lt;/span&gt;] == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;) || (Request.Cookies[&lt;span style="COLOR: maroon"&gt;"cnstUserRole"&lt;/span&gt;].Value == &lt;span style="COLOR: maroon"&gt;""&lt;/span&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User.Identity.Name == &lt;span style="COLOR: maroon"&gt;"admin1"&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        roles = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[1] { &lt;span style="COLOR: maroon"&gt;"admin"&lt;/span&gt; };&lt;span style="COLOR: green"&gt;//this info will be generally collected from database&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;HttpContext&lt;/span&gt;.Current.User.Identity.Name == &lt;span style="COLOR: maroon"&gt;"member1"&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        roles = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[1] { &lt;span style="COLOR: maroon"&gt;"member"&lt;/span&gt; };&lt;span style="COLOR: green"&gt;//this info will be generally collected from database&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        roles = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[1] { &lt;span style="COLOR: maroon"&gt;"public"&lt;/span&gt; };&lt;span style="COLOR: green"&gt;//this info will be generally collected from database                   &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: green"&gt;// Create a string to persist the role and user id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    userInformation = roles[0] + &lt;span style="COLOR: maroon"&gt;";"&lt;/span&gt; + Context.User.Identity.Name;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: green"&gt;// Create a cookie authentication ticket.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: teal"&gt;FormsAuthenticationTicket&lt;/span&gt; ticket = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;FormsAuthenticationTicket&lt;/span&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        1,                              &lt;span style="COLOR: green"&gt;// version&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        User.Identity.Name,             &lt;span style="COLOR: green"&gt;// user name&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now,                   &lt;span style="COLOR: green"&gt;// issue time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.AddHours(1),       &lt;span style="COLOR: green"&gt;// expires every hour&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;,                          &lt;span style="COLOR: green"&gt;// don't persist cookie&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        userInformation&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                        );&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: green"&gt;// Encrypt the ticket&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: teal"&gt;String&lt;/span&gt; cookieStr = &lt;span style="COLOR: teal"&gt;FormsAuthentication&lt;/span&gt;.Encrypt(ticket);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: green"&gt;// Send the cookie to the client&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    Response.Cookies[&lt;span style="COLOR: maroon"&gt;"cnstUserRole"&lt;/span&gt;].Value = cookieStr;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    Response.Cookies[&lt;span style="COLOR: maroon"&gt;"cnstUserRole"&lt;/span&gt;].Path = &lt;span style="COLOR: maroon"&gt;"/"&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    Response.Cookies[&lt;span style="COLOR: maroon"&gt;"cnstUserRole"&lt;/span&gt;].Expires = &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.AddMinutes(1);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                }&lt;span style="COLOR: green"&gt;//if role cookie not found in local pc&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;&lt;span style="COLOR: green"&gt;//we are getting the role info from cookie&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: green"&gt;// Get roles from roles cookie&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: teal"&gt;FormsAuthenticationTicket&lt;/span&gt; ticket = &lt;span style="COLOR: teal"&gt;FormsAuthentication&lt;/span&gt;.Decrypt(Context.Request.Cookies[&lt;span style="COLOR: maroon"&gt;"cnstUserRole"&lt;/span&gt;].Value);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    userInformation = ticket.UserData;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: green"&gt;//info[0] contains the single role and info[1] contains the user name&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[] cookieInfo = userInformation.Split(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;char&lt;/span&gt;[] { &lt;span style="COLOR: maroon"&gt;';'&lt;/span&gt; });&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                    roles = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[1] { cookieInfo[0] };&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                &lt;span style="COLOR: green"&gt;//now assign the user role in the current security context&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;                Context.User = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; System.Security.Principal.&lt;span style="COLOR: teal"&gt;GenericPrincipal&lt;/span&gt;(Context.User.Identity, roles);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;            }&lt;span style="COLOR: green"&gt;//if (Request.IsAuthenticated == true) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;    }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;Download source code: &lt;/font&gt;&lt;/p&gt;
&lt;p align="justify"&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: 26px; BACKGROUND-COLOR: #ffffff" marginwidth="0" marginheight="0" src="http://cid-907464dabda55b30.skydrive.live.com/embedrow.aspx/Community/role-based-security-with-caching.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;br /&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: 26px; BACKGROUND-COLOR: #ffffff" marginwidth="0" marginheight="0" src="http://cid-907464dabda55b30.skydrive.live.com/embedrow.aspx/Community/role-based-security-with-cookie.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:6a1653e8-6e74-4a49-bb68-4185dbf740fc" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/asp.net"&gt;asp.net&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/security"&gt;security&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/programming"&gt;programming&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/coding"&gt;coding&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/C#"&gt;C#&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/.net"&gt;.net&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=119718"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=119718" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/joycsharp/aggbug/119718.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Ashraful Alam</dc:creator>
            <guid>http://geekswithblogs.net/joycsharp/archive/2008/02/18/asp.net-role-based-security-the-basics.aspx</guid>
            <pubDate>Mon, 18 Feb 2008 10:31:40 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/joycsharp/comments/119718.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/joycsharp/archive/2008/02/18/asp.net-role-based-security-the-basics.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/joycsharp/comments/commentRss/119718.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/joycsharp/services/trackbacks/119718.aspx</trackback:ping>
        </item>
        <item>
            <title>Simple C# Delegate Sample</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2008/02/15/simple-c-delegate-sample.aspx</link>
            <description>&lt;p&gt;&lt;font face="ver" size="2"&gt;New developers often ask me about C# delegate, as they got a bit confused about the basic concept and specially maximum of the reference contains and discussed from an advanced view. Well I think delegate is really simple, when you grab it's basic idea. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;So what is delegate?&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;Basically it is similar like the old "C" age function pointer, where functions can be assigned like a variable and called in the run time based on dynamic conditions. C# delegate is the smarter version of function pointer which helps software architects a lot, specially while utilizing design patterns. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;At first, a delegate is defined with a specific signature (return type, parameter type and order etc). To invoke a delegate object, one or more methods are required with the EXACT same signature. A delegate object is first created similar like a class object created. The delegate object will basically hold a reference of a function. The function will then can be called via the delegate object. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;Sounds easy? If not lets have a look in the code snippets below.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;&lt;strong&gt;1. Defining the delegate&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: blue"&gt;public delegate int &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Calculate &lt;/span&gt;(&lt;span style="COLOR: blue"&gt;int &lt;/span&gt;value1, &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;value2);&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;&lt;strong&gt;2. Creating methods which will be assigned to delegate object&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: green"&gt;//a method, that will be assigned to delegate objects
//having the EXACT signature of the delegate
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;public int &lt;/span&gt;add(&lt;span style="COLOR: blue"&gt;int &lt;/span&gt;value1, &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;value2)
{
    &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;value1 + value2;            
}
&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: green"&gt;//a method, that will be assigned to delegate objects
//having the EXACT signature of the delegate
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;public int &lt;/span&gt;sub( &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;value1, &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;value2)
{
    &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;value1 - value2;            
}&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;h1&gt;&lt;font face="ver" size="2"&gt;&lt;strong&gt;3. Creating the delegate object and assigning methods to those delegate objects&lt;/strong&gt;&lt;/font&gt;&lt;/h1&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: green"&gt;//creating the class which contains the methods 
//that will be assigned to delegate objects
&lt;/span&gt;&lt;span style="COLOR: teal"&gt;MyClass &lt;/span&gt;mc = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: teal"&gt;MyClass&lt;/span&gt;();

&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: green"&gt;//creating delegate objects and assigning appropriate methods
//having the EXACT signature of the delegate
&lt;/span&gt;&lt;span style="COLOR: teal"&gt;Calculate &lt;/span&gt;add = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Calculate&lt;/span&gt;(mc.add);
&lt;span style="COLOR: teal"&gt;Calculate &lt;/span&gt;sub = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Calculate&lt;/span&gt;(mc.sub);&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;&lt;strong&gt;4. Calling the methods via delegate objects&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="ver"&gt;&lt;span style="COLOR: green"&gt;//using the delegate objects to call the assigned methods 
&lt;/span&gt;&lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Adding two values: " &lt;/span&gt;+ add(10, 6));
&lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Subtracting two values: " &lt;/span&gt;+ sub(10,4));&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;Pretty simple, huh? Happy coding!!&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;Download source code: &lt;/font&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-907464dabda55b30.skydrive.live.com/embedrowdetail.aspx/Community/simple-delegate-sample.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:973e6767-7c24-47f1-8673-fb8222e53cff" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/C#"&gt;C#&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/programming"&gt;programming&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/sample"&gt;sample&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/snippet"&gt;snippet&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/coding"&gt;coding&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;font face="ver" size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fgeekswithblogs.net%2fjoycsharp%2farchive%2f2008%2f02%2f15%2fsimple-c-delegate-sample.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fgeekswithblogs.net%2fjoycsharp%2farchive%2f2008%2f02%2f15%2fsimple-c-delegate-sample.aspx" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=119592"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=119592" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/joycsharp/aggbug/119592.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Ashraful Alam</dc:creator>
            <guid>http://geekswithblogs.net/joycsharp/archive/2008/02/15/simple-c-delegate-sample.aspx</guid>
            <pubDate>Fri, 15 Feb 2008 08:47:18 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/joycsharp/comments/119592.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/joycsharp/archive/2008/02/15/simple-c-delegate-sample.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/joycsharp/comments/commentRss/119592.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/joycsharp/services/trackbacks/119592.aspx</trackback:ping>
        </item>
        <item>
            <title>The .NET Framework 3.5 At a Glance</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2008/01/10/the-.net-framework-3.5-at-a-glance.aspx</link>
            <description>&lt;p&gt;All .NETTERS! Download the pdf poster &lt;a target="_blank" href="http://download.microsoft.com/download/4/a/3/4a3c7c55-84ab-4588-84a4-f96424a7d82d/NET35_Namespaces_Poster_LORES.pdf"&gt;here&lt;/a&gt; by which you can see .net 3.5 at a glance!&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/pandrew/archive/2007/11/02/announcing-the-net-framework-3-5-commonly-used-types-and-namespaces-poster.aspx"&gt;&lt;img alt="" src="http://blogs.msdn.com/blogfiles/pandrew/110207_2058_AnnouncingT1.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Check &lt;a target="_blank" href="http://blogs.msdn.com/pandrew/archive/2007/11/02/announcing-the-net-framework-3-5-commonly-used-types-and-namespaces-poster.aspx"&gt;Paul&lt;/a&gt;'s blog for a quick note!&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118429"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118429" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/joycsharp/aggbug/118429.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Ashraful Alam</dc:creator>
            <guid>http://geekswithblogs.net/joycsharp/archive/2008/01/10/the-.net-framework-3.5-at-a-glance.aspx</guid>
            <pubDate>Thu, 10 Jan 2008 06:46:54 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/joycsharp/comments/118429.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/joycsharp/archive/2008/01/10/the-.net-framework-3.5-at-a-glance.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/joycsharp/comments/commentRss/118429.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/joycsharp/services/trackbacks/118429.aspx</trackback:ping>
        </item>
        <item>
            <title>Creating a Performance Benchmark Framework for Your .NET Codes</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2007/11/22/117042.aspx</link>
            <description>&lt;p&gt;&lt;font face="ve"&gt;Performance is a one of the basic requirements in the most of the current trend of web applications. While designing software architecture, there are several technologies kept available for the designers. Among these available options, some of techniques may includes multiple solutions, combining of those can create a case, where the basic performance output can't be determined based on the common sense and/or in depth knowledge on the corresponding topics. In short, based upon different options the software architect needs to determine the appropriate object model which fits best with the current application requirement.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="ve" size="3"&gt;The Object Model&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ve"&gt;There are three layers of our test framework object model, as follows:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ve"&gt;&lt;strong&gt;The Program Class:&lt;/strong&gt; This is the starter class, which creates the requires instances to start the test operation. The corresponding caller method initializes the Runner class along with the number of iterations to be performed for each test case.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ve"&gt;&lt;strong&gt;The Runner Class:&lt;/strong&gt; The runner class includes one or multiple methods, which calls a bunch of methods of executor class, each of which contains required functionalities to call the test cases appropriately. &lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;ul&gt;
        &lt;li&gt;&lt;font face="ve"&gt;&lt;strong&gt;The Runner Base Class:&lt;/strong&gt; One important issue with respect to the runner class is, we need to have a way to keep track to execution time for each run and finally we need to determine the average execution time. For this purpose, to perform required initialization and support common reporting feature of test cases, we considered a base class, which includes all tracking data to isolate individual test cases and reporting functionalities. We have used C# delegate to have a very structured and reusable object model regarding this common functionalities. The methods of the inherited class uses this features accordingly. &lt;/font&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;font face="ve"&gt;&lt;strong&gt;The Executor Class:&lt;/strong&gt; The executor class contains the very basic codes with respect to a particular test case. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/joycsharp/WindowsLiveWriter/CreatingaPerformanceBenchmarkFr.NETCodes_D16E/ClassDiagram_4.png"&gt;&lt;font face="ve"&gt;&lt;img height="480" alt="ClassDiagram" width="515" src="http://geekswithblogs.net/images/geekswithblogs_net/joycsharp/WindowsLiveWriter/CreatingaPerformanceBenchmarkFr.NETCodes_D16E/ClassDiagram_thumb_1.png" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ve" size="3"&gt;&lt;strong&gt;The Sample Codes&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="ve" size="2"&gt;&lt;strong&gt;The  Program Class&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;&lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Program&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;    {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[] args)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;Output&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Test starts: "&lt;/span&gt; + &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.ToString());&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: green"&gt;//----------------------------------------&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;SampleRunner&lt;/span&gt; s1 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SampleRunner&lt;/span&gt;(10);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            s1.RunBenchmarks();&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: green"&gt;//----------------------------------------&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;Output&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Test ends: "&lt;/span&gt; + &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.ToString());&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.ReadLine();&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;    }&lt;/font&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;font face="ve" size="2"&gt;&lt;strong&gt;The Runner Base Class&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SampleRunnerBase&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;    {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;delegate&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; &lt;span style="COLOR: teal"&gt;DoWork&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; text);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;long&lt;/span&gt; _Start;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;long&lt;/span&gt; _Stop;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;double&lt;/span&gt; _Total = 0;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;double&lt;/span&gt; _TotalSecs;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;double&lt;/span&gt; _TotalAvgSecs;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; _Repeats;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; _RepeatsToDo; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; SampleRunnerBase(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; repeats)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            _RepeatsToDo = repeats;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Init()&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            _Total = 0;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            _TotalSecs = 0;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            _TotalAvgSecs = 0;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            _Repeats = _RepeatsToDo;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; ReportResults()&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            _TotalSecs = _Total / 10000000;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            _TotalAvgSecs = _Total / 10000000 / _RepeatsToDo;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;Output&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Avg: "&lt;/span&gt; + _TotalAvgSecs + &lt;span style="COLOR: maroon"&gt;" s"&lt;/span&gt;);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RunBenchmark(&lt;span style="COLOR: teal"&gt;DoWork&lt;/span&gt; func, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; text)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;null&lt;/span&gt; != func)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;                Init();&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;                &lt;span style="COLOR: blue"&gt;while&lt;/span&gt; (_Repeats-- &amp;gt; 0)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;                {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;                    _Start = &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.Ticks;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;                    func(text);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;                    _Stop = &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.Ticks;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;                    _Total += _Stop - _Start;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;                }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;                ReportResults();&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;    }&lt;/font&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;font face="ve" size="2"&gt;&lt;strong&gt;The Runner Class&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;sealed&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SampleRunner&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;SampleRunnerBase&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;    {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; SampleRunner(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; repeats)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            : &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(repeats)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RunBenchmarks()&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;Output&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Running Simple Sample Benchmark"&lt;/span&gt;);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;Output&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"--------------------------------"&lt;/span&gt;);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            RunSample1();&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            RunSample2();&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RunSample1()&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;Output&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Running Sample 1"&lt;/span&gt;);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;SampleExecutor&lt;/span&gt; runner = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SampleExecutor&lt;/span&gt;();&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            RunBenchmark(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;DoWork&lt;/span&gt; (runner.DoSample1), &lt;span style="COLOR: maroon"&gt;""&lt;/span&gt;);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RunSample2()&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;Output&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Running Sample 2"&lt;/span&gt;);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: teal"&gt;SampleExecutor&lt;/span&gt; runner = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SampleExecutor&lt;/span&gt;();&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            RunBenchmark(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;DoWork&lt;/span&gt;(runner.DoSample2), &lt;span style="COLOR: maroon"&gt;""&lt;/span&gt;);&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;    }&lt;/font&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="ve" size="2"&gt;The Executor Class&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SampleExecutor&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;    {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; DoSample1(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; text)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: green"&gt;//do something&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; DoSample2(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; text)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        {&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;            &lt;span style="COLOR: green"&gt;//do something&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;        }&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;font face="ve"&gt;    }&lt;/font&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;font face="ve"&gt; Download source code: &lt;/font&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-907464dabda55b30.skydrive.live.com/embedrowdetail.aspx/Community/performance-framework.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:6a2344da-89be-44f9-939b-36333a38defd" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/Performance"&gt;Performance&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/.net"&gt;.net&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/C#"&gt;C#&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Testing"&gt;Testing&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Framework"&gt;Framework&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Benchmark"&gt;Benchmark&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fgeekswithblogs.net%2fjoycsharp%2farchive%2f2007%2f11%2f22%2f117042.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fgeekswithblogs.net%2fjoycsharp%2farchive%2f2007%2f11%2f22%2f117042.aspx" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=117042"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=117042" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/joycsharp/aggbug/117042.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Ashraful Alam</dc:creator>
            <guid>http://geekswithblogs.net/joycsharp/archive/2007/11/22/117042.aspx</guid>
            <pubDate>Thu, 22 Nov 2007 10:32:48 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/joycsharp/comments/117042.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/joycsharp/archive/2007/11/22/117042.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/joycsharp/comments/commentRss/117042.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/joycsharp/services/trackbacks/117042.aspx</trackback:ping>
        </item>
        <item>
            <title>Performing Long Running Operation with Asynchronous Page in ASP.NET 2.0</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2007/11/22/117039.aspx</link>
            <description>&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8284517b-bea9-4aa5-ac11-f3d7009ea9ab" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/asp.net"&gt;asp.net&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/async"&gt;async&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/web%20service"&gt;web service&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/performance"&gt;performance&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/database"&gt;database&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/joycsharp/WindowsLiveWriter/AsyncPageinASP.NET2.0_A9C1/fire_2.jpg"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="144" alt="fire" width="190" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/joycsharp/WindowsLiveWriter/AsyncPageinASP.NET2.0_A9C1/fire_thumb.jpg" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;There are few cases in current web applications, where it involves long running operations. For instance, a system admin uploads 1 gig of data in the system, which will be processed by the system for 30-40 minutes to be splitted and putted properly in the database system, as well as notifying other system user regarding the availability if data. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;In the traditional approach of web application, the user has to wait for the whole time until the whole process needs to be completed. The modern age of web application includes a technique where the user doesn't required to be wait to complete the whole process with the current page, where as they can move on other page (or even can close the browser) or if they resides on that page the system will show a simple progress bar , which stops when the data processing (or the long running operation) completes. The corresponding technique that implies this usability feature is using an asynchronous model. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Before the asp.net 2.0 ages, creating an asynchronous model was very complex and time consuming along with several over-heads. ASP.NET 2.0 comes with a new nice feature, where we can declare and use a page easily in asynchronous style. Besides the easy implementation model, ASP.NET asynchronous page utilizes ASP.NET threads efficiently. While calling a long running database query or web service, at the moment the request reaches at the asynchronous point, the corresponding asynchronous operation starts without keeping the current ASP.NET allocated, and thus lets the thread to be returned back to the thread pool. As soon as the asynchronous process completes, another ASP.NET thread get allocated and continues accordingly. This model really improves the utilization of ASP.NET thread pool and thus improves the scalability of the corresponding web applications. More can be found &lt;/font&gt;&lt;a target="_blank" href="http://msdn.microsoft.com/msdnmag/issues/07/03/WickedCode/"&gt;&lt;font face="Verdana" size="2"&gt;here&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana" size="2"&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;To make a web page asynchronous, we just have to put a property in the page directive as follows:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="Verdana" size="2"&gt;&amp;lt;%@ Page Async="true" ...&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;There are two different implementation model for ASP.NET 2.0 asynchronous pages, with respect to database and web-service call. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="Arial" size="3"&gt;Implementation model for database&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;The implementation model for database query requires a "PageAsyncTask" class to be set with few event handler methods such as "Begin Event Handler", "End Event Handler", "Timeout Event Handler" etc. This task should be registered as an Asynchronous tasks to continue and complete the asynchronous scenario properly.&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;partial&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;AsyncPageTask&lt;/span&gt; : System.Web.UI.&lt;span style="COLOR: teal"&gt;Page&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;{&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SqlConnection&lt;/span&gt; _connection;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SqlCommand&lt;/span&gt; _command;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SqlDataReader&lt;/span&gt; _reader;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: teal"&gt;IAsyncResult&lt;/span&gt; BeginAsyncOperation(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: teal"&gt;EventArgs&lt;/span&gt; e, &lt;span style="COLOR: teal"&gt;AsyncCallback&lt;/span&gt; cb, &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; state)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    {&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        Response.Write(&lt;span style="COLOR: maroon"&gt;"Starts at: "&lt;/span&gt; + &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.ToString());&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        _command = &lt;span style="COLOR: teal"&gt;DAL&lt;/span&gt;.GetCommandForInsertRecord();&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        _connection = _command.Connection;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; _command.BeginExecuteReader(cb, state);&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    }&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; EndAsyncOperation(&lt;span style="COLOR: teal"&gt;IAsyncResult&lt;/span&gt; ar)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    {&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        _reader = _command.EndExecuteReader(ar);&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        Response.Write(&lt;span style="COLOR: maroon"&gt;" Ends at: "&lt;/span&gt; + &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.ToString());&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    }&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; TimeoutAsyncOperation(&lt;span style="COLOR: teal"&gt;IAsyncResult&lt;/span&gt; ar)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    {&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    }&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Dispose()&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    {&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (_connection != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            _connection.Close();&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.Dispose();&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    }&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; btnClick_Click(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: teal"&gt;EventArgs&lt;/span&gt; e)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    {&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        Response.Write(&lt;span style="COLOR: maroon"&gt;"Hello "&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        &lt;span style="COLOR: teal"&gt;PageAsyncTask&lt;/span&gt; task = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PageAsyncTask&lt;/span&gt;(&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;BeginEventHandler&lt;/span&gt;(BeginAsyncOperation),&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;EndEventHandler&lt;/span&gt;(EndAsyncOperation),&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;EndEventHandler&lt;/span&gt;(TimeoutAsyncOperation),&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        );&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        RegisterAsyncTask(task);&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    }&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;font face="Arial" size="3"&gt;&lt;strong&gt;Implementation model for web service&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;The implementation model for web service call is much more simpler than the database query. Ii just includes creating an web service instance, followed by calling the MethodName"Async" (for instance, if the web method name is "HelloWorld" then its asynchronous method name is "HelloWorldAsync". Besides the calling the asynchronous method for a web service method, we can register it's complete event handler to perform some post completion tasks.&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; btnClick_Click(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: teal"&gt;EventArgs&lt;/span&gt; e)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    {&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        Response.Write(&lt;span style="COLOR: maroon"&gt;"Starts at: "&lt;/span&gt; + &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.ToString());&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        MyWebService.&lt;span style="COLOR: teal"&gt;WebService&lt;/span&gt; MyWS = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; MyWebService.&lt;span style="COLOR: teal"&gt;WebService&lt;/span&gt;();&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        MyWS.HelloWorldCompleted += &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; MyWebService.&lt;span style="COLOR: teal"&gt;HelloWorldCompletedEventHandler&lt;/span&gt;(MyWS_HelloWorldCompleted);&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        MyWS.HelloWorldAsync();&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    }&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; MyWS_HelloWorldCompleted(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, MyWebService.&lt;span style="COLOR: teal"&gt;HelloWorldCompletedEventArgs&lt;/span&gt; e)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    {&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        Response.Write(&lt;span style="COLOR: maroon"&gt;" Ends at: "&lt;/span&gt; + &lt;span style="COLOR: teal"&gt;DateTime&lt;/span&gt;.Now.ToString());&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    }&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;Download Source code: &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-907464dabda55b30.skydrive.live.com/embedrowdetail.aspx/Community/asp.net-async-page.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fgeekswithblogs.net%2fjoycsharp%2farchive%2f2007%2f11%2f22%2f117039.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fgeekswithblogs.net%2fjoycsharp%2farchive%2f2007%2f11%2f22%2f117039.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=117039"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=117039" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/joycsharp/aggbug/117039.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Ashraful Alam</dc:creator>
            <guid>http://geekswithblogs.net/joycsharp/archive/2007/11/22/117039.aspx</guid>
            <pubDate>Thu, 22 Nov 2007 07:29:04 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/joycsharp/comments/117039.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/joycsharp/archive/2007/11/22/117039.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/joycsharp/comments/commentRss/117039.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/joycsharp/services/trackbacks/117039.aspx</trackback:ping>
        </item>
        <item>
            <title>Efficient Batch Operation From ASP.NET 2.0 Using SQL Server 2005 XML Data Type</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2007/11/19/116933.aspx</link>
            <description>&lt;p&gt;&lt;font size="2"&gt;One of the good practice while developing high performance web application is to reduce the database roundtrip as much as possible. In the current trend of web applications, its a very common to enable users to delete multiple items in a list user interface at a time.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/joycsharp/WindowsLiveWriter/f803cbd01dba_D8CF/list.png"&gt;&lt;font color="#333333" size="2"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="167" alt="list" width="244" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/joycsharp/WindowsLiveWriter/f803cbd01dba_D8CF/list_thumb.png" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;To perform this type of batch delete operation, one common mistake that happens by beginner developers are to calling the data access method repetitively for each item with in a loop as below:&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;span style="COLOR: blue"&gt;For&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Each&lt;/span&gt; row &lt;span style="COLOR: blue"&gt;As&lt;/span&gt; GridViewRow &lt;span style="COLOR: blue"&gt;In&lt;/span&gt; gvEmployees.Rows&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            &lt;span style="COLOR: green"&gt;' Access the CheckBox &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;Dim&lt;/span&gt; cb &lt;span style="COLOR: blue"&gt;As&lt;/span&gt; CheckBox = &lt;span style="COLOR: blue"&gt;CType&lt;/span&gt;(row.FindControl(&lt;span style="COLOR: maroon"&gt;"chkEmployeeSelector"&lt;/span&gt;), CheckBox)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;If&lt;/span&gt; cb &lt;span style="COLOR: blue"&gt;IsNot&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Nothing&lt;/span&gt; &lt;span style="COLOR: blue"&gt;AndAlso&lt;/span&gt; cb.Checked &lt;span style="COLOR: blue"&gt;Then&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;                &lt;span style="COLOR: green"&gt;' First, get the EmployeeID for the selected row &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;                &lt;span style="COLOR: blue"&gt;Dim&lt;/span&gt; employeeId &lt;span style="COLOR: blue"&gt;As&lt;/span&gt; SqlInt32 = &lt;span style="COLOR: blue"&gt;CType&lt;/span&gt;(gvEmployees.DataKeys(row.RowIndex).Value, SqlInt32)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;                &lt;span style="COLOR: green"&gt;' Deleting a employee... &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;                DAL.Employee.Delete.(employeeId) &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;End&lt;/span&gt; &lt;span style="COLOR: blue"&gt;If&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;span style="COLOR: blue"&gt;Next&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;A good approach regarding this issue is to send all of the employee id's at a time to the database stored procedure, so that all the deletion operation can be handled at a time, and thus reducing the cost with respect to database roundtrip! BUT one basic problem with this approach is SQL Server doesn't support array, and thus we can't pass the list of ID's as an array! Then? &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Oh yes! We have XML data type available is SQL Server 2005, well we can utilize that concept easily. How? Easy! Just to create the list as an xml and then pass to the corresponding stored procedure. The stored procedure will extract the xml accordingly and perform required operation individually on each item. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;Application End:&lt;/strong&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;The method below converts a .net generic list to a xml representation of list of Id's which is passed to stored procedure to perform required batch operation:  &lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; FormatXMLForIdArray(System.Collections.Generic.&lt;span style="COLOR: teal"&gt;List&lt;/span&gt;&amp;lt;SqlInt32&amp;gt; idsToList)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    {&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        &lt;span style="COLOR: green"&gt;//converting the list to xml first &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        StringBuilder xmlString = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; StringBuilder();&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        &lt;span style="COLOR: blue"&gt;for&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; i = 0; i &amp;lt; idsToList.Count; i++)&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        {&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;            xmlString.AppendFormat(&lt;span style="COLOR: maroon"&gt;"&amp;lt;Id&amp;gt;{0}&amp;lt;/Id&amp;gt;"&lt;/span&gt;, idsToList[i]);&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        }&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;        &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; xmlString.ToString();&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    } &lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;Stored Procedure End:&lt;/strong&gt; &lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;span style="COLOR: blue"&gt;ALTER PROCEDURE &lt;/span&gt;spr_Employee_DeleteEmployeeList &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;@EmployeeSystemUserIdList xml &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;span style="COLOR: blue"&gt;AS &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;span style="COLOR: blue"&gt;DELETE &lt;/span&gt;App_Employee &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;&lt;span style="COLOR: blue"&gt;WHERE &lt;/span&gt;EmployeeSystemUserId &lt;span style="COLOR: blue"&gt;in &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;( &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;SELECT &lt;/span&gt;ParamValues.EmployeeSystemUserId.value(&lt;span style="COLOR: maroon"&gt;'.'&lt;/span&gt;,&lt;span style="COLOR: maroon"&gt;'Int'&lt;/span&gt;) &lt;span style="COLOR: blue"&gt;as &lt;/span&gt;Id &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;    &lt;span style="COLOR: blue"&gt;FROM &lt;/span&gt;@EmployeeSystemUserIdList.nodes(&lt;span style="COLOR: maroon"&gt;'/EmployeeSystemUserId'&lt;/span&gt;) &lt;span style="COLOR: blue"&gt;as &lt;/span&gt;ParamValues(EmployeeSystemUserId) &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;) &lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt; &lt;/p&gt;
&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=116933"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=116933" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/joycsharp/aggbug/116933.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Ashraful Alam</dc:creator>
            <guid>http://geekswithblogs.net/joycsharp/archive/2007/11/19/116933.aspx</guid>
            <pubDate>Mon, 19 Nov 2007 09:52:50 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/joycsharp/comments/116933.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/joycsharp/archive/2007/11/19/116933.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/joycsharp/comments/commentRss/116933.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/joycsharp/services/trackbacks/116933.aspx</trackback:ping>
        </item>
        <item>
            <title>Few Words From A Fresh MVP</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2007/01/03/102594.aspx</link>
            <description>&lt;p&gt;&lt;img height="179" width="113" alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/joycsharp/5809/o_mvp_logo.jpg" /&gt; &lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;One of the famous quotes of Socrates that drives me all the time is: "Know Thyself". Around the world there are lots of things which might be in your interest on not. Knowing yourself doesn't only mean to find your choices, it also includes the facts, which don't belong to your choice as well as! &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="Verdana" size="2"&gt;Knowing what I don't know&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Well, so I need to know myself. As a technical guy, how do I know where I can be the best fit or where I can be comfortable to explore my ideas to create new but necessary things? One of our favorite poets, Rabindranath Thakur told "It's very natural to be ignorant about something. But it often happens that, we don't know what we don't know!". In this very dynamic era of technical world, it is very much true. Technology is changing very frequently, so as professionals, always we need to find out best fits among all of the changes. To knowing about "what I don't know" was my first step to go forward. Of course, community contents, such as forums, articles, blogs, newsgroups was a great resource for me in that case, by getting informed what the experts and professionals are thinking about the latest software releases and development practices. Going thru among those, I got the basic idea about what I don't really know! &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="Verdana" size="2"&gt;Learning in-depth where I can be a best fit&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;After experimenting and picking my choices, the next phase starts! I need to learn those in more detail. One of my most favorite quote about IT professionals is "To fit with current tech trend, we need to know something about everything and we need to know everything about something!". In real tech world, the term "everything" can't be limited within a specific boundary. So it's better to consider the term, "everything" is "as much as possible". &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="Verdana" size="2"&gt;Implementation&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Now the third phase to explore as a good professional, appears. Use what you have learned in your projects/works. But apart from simply putting the learned things should not be the "only" concern for a developer. While implementing any external content that I just learned, I tried to keep my eyes open to examine it's affect in the production environment. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="Verdana" size="2"&gt;Turning to personal contribution over the contents&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Either comparing with other alternative solutions or analyzing the solution with respect to other dependencies, I often got some new ideas, thoughts, techniques to modify the used solution for the current project or for the future project with different context. This process not only makes me intimate with the contents in more details, but also opens several doors to provide the best solution in appropriate context. Apart from my personal usage, these alternative or better solutions can also be a valuable resource to my community friends, along with providing them a way to think more about it!&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;The four phases, which I just mentioned are my usual way to expand my knowledge (and thus myself) in most comfortable scenario. Thanks God, technology is changing very frequently, and thus always I can discover myself in an infinite loop! &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="Verdana" size="2"&gt;My MVP 2007 Award &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Once upon a time, I was a freelance newspaper journalist. I first used PC when I was in the second semester in my Bachelor in Computer Science degree! As usually, I was a bit afraid, whether i will be able to fit in this "unknown" area. The continuous process to knowing me opened doors for me to find myself to be fitted here. Besides my reference books, my community friends were a great resource for me. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Passing previous 7 years was a great adventure for me! Getting matured with the community contents and tutorial stuffs, one day I found that, besides getting, I can put my contents to my community friends as well as. The most interesting thing I felt, that, besides getting contents from the community, there is a big "joy" to share own contents in return. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Microsoft awarded me first time as a &lt;/font&gt;&lt;a target="_blank" href="https://mvp.support.microsoft.com"&gt;&lt;font face="Verdana" size="2"&gt;MVP "Most Valuable Professional"&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana" size="2"&gt; in "Visual ASP.NET" category for 2007, with respect to my community contributions over the last year 2006. My MVP profile can be seen &lt;/font&gt;&lt;a target="_blank" href="https://mvp.support.microsoft.com/profile=34001707-BA01-4FAF-AA19-54BD382FE989"&gt;&lt;font face="Verdana" size="2"&gt;here&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana" size="2"&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Of course it was a big surprise for me to find myself in an expert community. Apart from other benefits, I feel the best thing, to get a broader scope to get in touch with the Tech gurus. Thanks to Microsoft to provide me a new path to go forward with more perfection!&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Cheers!&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=102594"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=102594" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/joycsharp/aggbug/102594.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Ashraful Alam</dc:creator>
            <guid>http://geekswithblogs.net/joycsharp/archive/2007/01/03/102594.aspx</guid>
            <pubDate>Wed, 03 Jan 2007 04:39:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/joycsharp/comments/102594.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/joycsharp/archive/2007/01/03/102594.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/joycsharp/comments/commentRss/102594.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/joycsharp/services/trackbacks/102594.aspx</trackback:ping>
        </item>
        <item>
            <title>ASP.NET 2.0 Deployment: Some Common Considerations</title>
            <link>http://geekswithblogs.net/joycsharp/archive/2006/11/25/98771.aspx</link>
            <description>&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Regarding the previous ages of VS.NET 2005,&amp;nbsp;web project deployment was pretty simple,&amp;nbsp;but with limited options.&amp;nbsp;For different types of projects, you may have different types of deployment requirements. For example, you may wish only to&amp;nbsp;update the dll or contents for each component of the project separately,&amp;nbsp;specially&amp;nbsp;if the project is too big to take much time to upload the components &amp;nbsp;each time. For smaller projects, it would be great if we can upload only one file to reflect the new changes of a project.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;In the age of VS.NET 2005, I found that there several options have been offered to developers, initially which may make the developers confused. Basically there are two basic issues which should be considered at the top level of deployment design.&amp;nbsp;One is content based and the another one is assembly based. When publishing a web site, there are two options are in place in this issue, which are being discussed here respectively.&amp;nbsp;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;img height="402" src="http://geekswithblogs.net/images/geekswithblogs_net/joycsharp/5809/o_VS_Deploy.gif" width="473"&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Verdana" size="2"&gt;1. Allow this precompiled site to be updatable&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;In ASP.NET deployment, we can put the aspx files in corresponding locations, just as a place holder, where the contents will be placed in the corresponding .compile file in the bin folder, which can be enabled by making this option false. In that case, the following issues should be reminded:&lt;/font&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;a. .compile file and the corresponding file should be placed for each update of&amp;nbsp;a given aspx, master file. If there is only change is code-behind class (i.e. code), this file should be included too. &lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;b. For code change in App_Code, no need to copy App_Code.compiled, just copy App_Code.dll ( so far I learned!). &lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;c. For code change in Global.asax, no need to copy App_global.asax.compiled, just copy App_global.asax.dll ( so far I learned!). &lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;d. For changes in CSS files of App_themes CSS should be copied manually. (I don't have tested image and skin files yet!). &lt;/font&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;Any way, if this option is true, the deployment still requires .compiled file, but not for the pages, but for App_Code folder, App_global.asax files, which will be used as a resource locator.&amp;nbsp;So any changes to these contents doesn't require to upload this files for the maximum time. I am not sure when the updated version of these files should be deployed, but to deploy the updated version of these files&amp;nbsp;is a recommended practice!&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Verdana" size="2"&gt;2. Use fixed naming and single page assemblies&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;For deploying assemblies of a ASP.NET 2.0 projects there are three ways to do:&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;a. Single page assembly: &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;In Visual Studio 2005, for a ASP.NET 2.0 web application, we can deploy separate assemblies for each pages of the site! This can be done by enabling the above option. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;If the ' Allow this precompiled site to be updatable' is disabled, that means&amp;nbsp;a corresponding .compile file should also be deployed with the assembly of each page. In this case, if there is any change &amp;nb