<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code Junkie : .NET</title><link>http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx</link><description>Tags: .NET</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>TAM v3.0 beta is live!</title><link>http://blogs.msdn.com/codejunkie/archive/2009/07/21/tam-v3-0-beta-is-live.aspx</link><pubDate>Tue, 21 Jul 2009 21:33:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9843639</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9843639.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9843639</wfw:commentRss><description>&lt;p&gt;A new version of threat analysis and modeling tool has been released. This version has significant improvements from previous version as identified in previous posts. You can find more information on the download link and bugs link from &lt;a title="TAM 3.0 Beta is Now Live!" href="http://blogs.msdn.com/securitytools/archive/2009/07/21/tam-3-0-beta-is-now-live.aspx"&gt;TAM 3.0 Beta is Now Live!&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Thanks   &lt;br /&gt;RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9843639" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category></item><item><title>Connection String Injection Attack</title><link>http://blogs.msdn.com/codejunkie/archive/2009/07/20/connection-string-injection-attack.aspx</link><pubDate>Tue, 21 Jul 2009 00:58:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9842364</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9842364.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9842364</wfw:commentRss><description>&lt;p&gt;Today I was looking at some new classes in .NET 2.0 and stumbled across DbConnectionStringBuilder class. This class provides compile time checks around building connection strings with user input. If you are constructing connection string dynamically by accepting server name from the&amp;#160; user you could be vulnerable to this attack. Here is an example on how to mitigate that using SqlConnectionStringBuilder class.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;System.Data.SqlClient.SqlConnectionStringBuilder builder =
  &lt;span class="kwrd"&gt;new&lt;/span&gt; System.Data.SqlClient.SqlConnectionStringBuilder();
builder[&lt;span class="str"&gt;&amp;quot;Data Source&amp;quot;&lt;/span&gt;] = &lt;span class="str"&gt;&amp;quot;(local)&amp;quot;&lt;/span&gt;;
builder[&lt;span class="str"&gt;&amp;quot;Integrated Security&amp;quot;&lt;/span&gt;] = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
builder[&lt;span class="str"&gt;&amp;quot;Initial Catalog&amp;quot;&lt;/span&gt;] = &lt;span class="str"&gt;&amp;quot;AdventureWorks&amp;quot;&lt;/span&gt;;
builder[&lt;span class="str"&gt;&amp;quot;Persist Security Info&amp;quot;&lt;/span&gt;] = &lt;span class="str"&gt;&amp;quot;false&amp;quot;&lt;/span&gt;;
Console.WriteLine(builder.ConnectionString);&lt;/pre&gt;

&lt;p&gt;&lt;style type="text/css"&gt;
.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; }&lt;/style&gt;If you re using user input to create a connection string, you must use this class. Additionally you should perform input validation before passing data to this class. For more information about this class and generic connection string security check the following links.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms254947.aspx"&gt;Connection String Builders (ADO.NET)&lt;/a&gt;

  &lt;br /&gt;&lt;a href="http://msmvps.com/blogs/williamryan/archive/2006/01/15/81115.aspx"&gt;Using the SqlConnectionStringBuilder to guard against Connection String Injection Attacks&lt;/a&gt;

  &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/89211k9b(VS.80).aspx"&gt;Securing Connection Strings&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks
  &lt;br /&gt;Anil&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9842364" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category></item><item><title>AJAX approach to localizing Date Time</title><link>http://blogs.msdn.com/codejunkie/archive/2009/05/29/ajax-approach-to-localizing-date-time.aspx</link><pubDate>Fri, 29 May 2009 18:48:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9653477</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9653477.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9653477</wfw:commentRss><description>&lt;p&gt;I am pretty confident most of you people out there have developed web applications for global use which display date time according to the user’s local time zone. Although it is possible to do this on the server side, it is very efficient and easy to do this on the client side specially on the browser as JavaScript inherently provides Date() object which does UTC to Local conversion.&lt;/p&gt;  &lt;p&gt;Imagine you have lot of labels and text boxes which require you to convert UTC date and time to local date and time. With the help of AJAX extenders you can do this on the client side very easily. So I have written an AJAX extender which runs on the client side to do the conversion automatically. When attached to a label or text box it will get the date and time in the control and convert it to the local date and time.&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="511"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="509"&gt;         &lt;p&gt;&amp;lt;asp:Label ID=&amp;quot;DateLabel&amp;quot; runat=&amp;quot;server&amp;quot; Text='&amp;lt;%#Eval(&amp;quot;Date&amp;quot;) %&amp;gt;' /&amp;gt;            &lt;br /&gt;&amp;lt;cc2:UTCToLocalExtenderControl ID=&amp;quot;UTCToLocalExtenderControl1&amp;quot; runat=&amp;quot;server&amp;quot; TargetControlID=&amp;quot;DateLabel&amp;quot; DateTimeFormatString=&amp;quot;g&amp;quot; /&amp;gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Majority of the work is being done in the extender behavior.js file.&lt;/p&gt;  &lt;p&gt;Thanks    &lt;br /&gt;Anil&lt;/p&gt; &lt;iframe style="border-bottom: #dde5e9 1px solid; border-left: #dde5e9 1px solid; padding-bottom: 0px; margin: 3px; padding-left: 0px; width: 240px; padding-right: 0px; height: 26px; border-top: #dde5e9 1px solid; border-right: #dde5e9 1px solid; padding-top: 0px" marginheight="0" src="http://cid-216e75b3465e4428.skydrive.live.com/embedrow.aspx/Public/CISFAjaxExtenders.zip" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9653477" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/CISG/default.aspx">CISG</category></item><item><title>System.Security.SecureString Part II</title><link>http://blogs.msdn.com/codejunkie/archive/2008/12/18/system-security-securestring-part-ii.aspx</link><pubDate>Thu, 18 Dec 2008 03:11:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9232779</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9232779.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9232779</wfw:commentRss><description>&lt;p&gt;Second part of the SecreString blog post. Check it out at &lt;a title="http://blogs.msdn.com/cisg/archive/2008/12/17/secure-string-in-net-part-ii.aspx" href="http://blogs.msdn.com/cisg/archive/2008/12/17/secure-string-in-net-part-ii.aspx"&gt;http://blogs.msdn.com/cisg/archive/2008/12/17/secure-string-in-net-part-ii.aspx&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Thanks    &lt;br /&gt;RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9232779" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category></item><item><title>How the Anti-XSS 3.0 SRE Works</title><link>http://blogs.msdn.com/codejunkie/archive/2008/12/16/how-the-anti-xss-3-0-sre-works.aspx</link><pubDate>Tue, 16 Dec 2008 22:03:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9227500</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9227500.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9227500</wfw:commentRss><description>&lt;p&gt;Published a new blog on how SRE works internally. Kind of a starter course on Anti-XSS SRE code. Check it out at &lt;a title="How the Anti-XSS 3.0 SRE Works" href="http://blogs.msdn.com/cisg/archive/2008/12/16/how-the-anti-xss-3-0-sre-works.aspx"&gt;How the Anti-XSS 3.0 SRE Works&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Thanks   &lt;br /&gt;RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9227500" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category></item><item><title>Anti-XSS Webcast</title><link>http://blogs.msdn.com/codejunkie/archive/2008/12/10/anti-xss-webcast.aspx</link><pubDate>Wed, 10 Dec 2008 04:13:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9188601</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9188601.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9188601</wfw:commentRss><description>&lt;p&gt;On January 9th there will be a webcast on technet about Anti-XSS v3.0. This will showcase some of the improvements done to the Anti-XSS library. The webcast registration url is &lt;a title="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032398771&amp;amp;Culture=en-US" href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032398771&amp;amp;Culture=en-US"&gt;http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032398771&amp;amp;Culture=en-US&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Thanks   &lt;br /&gt;RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9188601" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/CISG/default.aspx">CISG</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Talks/default.aspx">Talks</category></item><item><title>Security Deployment Review Tool Webcast</title><link>http://blogs.msdn.com/codejunkie/archive/2008/12/04/security-deployment-review-tool-webcast.aspx</link><pubDate>Thu, 04 Dec 2008 20:48:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9175935</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9175935.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9175935</wfw:commentRss><description>&lt;p&gt;Deployment Reviews is a process to check a host for security settings, mostly those affect the applications that are hosted on that. A technet webcast has been scheduled to reveal an automated tool to check for deployment security settings. The webcast is on 12/15/2008 from 10:30 AM to 11:30 AM and the following is the registration link for the webcast.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032396517&amp;amp;Culture=en-US " href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032396517&amp;amp;Culture=en-US "&gt;http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032396517&amp;amp;Culture=en-US &lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Thanks   &lt;br /&gt;RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9175935" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Talks/default.aspx">Talks</category></item><item><title>Oslo M Language</title><link>http://blogs.msdn.com/codejunkie/archive/2008/11/10/oslo-m-language.aspx</link><pubDate>Tue, 11 Nov 2008 00:58:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9058771</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9058771.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9058771</wfw:commentRss><description>&lt;p&gt;The M language is awesome, I have been experimenting with it for quite some time now. it allows you to create models of types in a descriptive language. The idea behind M language is to capture developers intent in a descriptive language for modeling purposes. Additionally, it converts these types into SQL schema for application storage. Imagine if you have a type called Developer you could then create data for the types, write methods for the types etc. All of this will be automatically converted into T-SQL Tables, Views and Functions to be created in SQL Server. Once you have these tables and views, you can use any middle ware to write data to these views. In essence, you no longer need to create sql tables using sql management studio, just create the types in M language and you are good to go. M language syntax also supports LINQ expressions which could be used to write powerful methods which are created as functions in SQL. The following is a sample type, and attached is the SQL code for it which was automatically generated. &lt;/p&gt;  &lt;p&gt;module CISGType    &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; type Developer    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FirstName : Text where value.Count &amp;lt;=255;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LastName : Text;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ID : Integer32 = AutoNumber();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } where identity(ID);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; Developers : Developer*    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { FirstName=&amp;quot;Anil&amp;quot;,LastName=&amp;quot;Revuru&amp;quot; },    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { FirstName=&amp;quot;Anil&amp;quot;, LastName=&amp;quot;Chintala&amp;quot; },    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { FirstName=&amp;quot;Mark&amp;quot;, LastName=&amp;quot;Curphey&amp;quot; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;As shown in above example you can do bunch load of things with this, you could put constraints on the type members, auto generate identifiers, specify identity columns etc. Check the full list in M Language reference. Here are some more links for M language. If you want to get started look at the PDC 2008 video and download the SDK. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd129870.aspx"&gt;M Grammar in nutshell&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd129519(VS.85).aspx"&gt;M Language Reference&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/oslo/default.aspx"&gt;Oslo Developer MSDN Page&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://code.msdn.microsoft.com/oslo/Release/ProjectReleases.aspx?ReleaseId=1707"&gt;Oslo SDK Download&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://channel9.msdn.com/pdc2008/TL27/"&gt;PDC 2008 OSLO video&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Thanks   &lt;br /&gt;Anil RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9058771" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category></item><item><title>SECURITY Q&amp;A #1</title><link>http://blogs.msdn.com/codejunkie/archive/2008/11/07/security-q-a-1.aspx</link><pubDate>Fri, 07 Nov 2008 03:37:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9051026</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9051026.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9051026</wfw:commentRss><description>&lt;p&gt;From a security perspective what's wrong with this code?&lt;/p&gt;  &lt;div&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &amp;lt;html&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &amp;lt;head&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; &amp;lt;title&amp;gt;Welcome Page&amp;lt;/title&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; &amp;lt;script language=&lt;span style="color: #006080"&gt;&amp;quot;JavaScript&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; function openNewWindow()&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;    window.open(&lt;span style="color: #006080"&gt;'&amp;lt;%=Server.HtmlEncode(Request.QueryString[&amp;quot;URL&amp;quot;])%&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt; }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt; &amp;lt;/script&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt; &amp;lt;/head&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt; &amp;lt;body&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt; Welcome &amp;lt;%=Context.User.Identity.Name %&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt; &amp;lt;br/&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt; Click &amp;lt;a href=&lt;span style="color: #006080"&gt;&amp;quot;javascript:openNewWindow();&amp;quot;&lt;/span&gt;&amp;gt;here&amp;lt;/a&amp;gt; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt; to open the link &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; window.  15: &amp;lt;/body&amp;gt;  16: &amp;lt;/html&amp;gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Answer: 2 bugs. I always start with input and see where it is going. We have two inputs here, one is from a query string (line 7) and the other one is from context (line 12). First lets start with line 7, it is very obvious that QueryString data is untrusted so the developer is encoding it using Server.HtmlEncode. But Server.HtmlEncode does not work inside JavaScript as it does not encode all bad characters, thus this is a bug. For more information on what Server.HtmlEncode does check this &lt;a title="http://blogs.msdn.com/cisg/archive/2008/08/28/output-encoding.aspx" href="http://blogs.msdn.com/cisg/archive/2008/08/28/output-encoding.aspx"&gt;http://blogs.msdn.com/cisg/archive/2008/08/28/output-encoding.aspx&lt;/a&gt;. Second input seems to be benign as it is just username which is usually simple. Wrong, in cases where user registers on the site, and wishes to give any username he wants he could very well put javascript in it which will in turn be returned by Identity.Name. Line 12 also need to be output encoded using AntiXss library. &lt;/p&gt;

&lt;p&gt;More AntiXss Library blogs:&lt;/p&gt;

&lt;p&gt;&lt;a title="What is the Microsoft Anti-XSS Library-" href="http://blogs.msdn.com/cisg/archive/2008/08/26/what-is-microsoft-antixss.aspx"&gt;What is the Microsoft Anti-XSS Library-&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a title="Real World XSS Vulnerabilities in ASP.NET Code" href="http://blogs.msdn.com/cisg/archive/2008/09/10/real-world-xss-vulnerabilities-in-asp-net-code.aspx"&gt;Real World XSS Vulnerabilities in ASP.NET Code&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9051026" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category></item><item><title>Developer Security IQ</title><link>http://blogs.msdn.com/codejunkie/archive/2008/11/07/developer-security-iq.aspx</link><pubDate>Fri, 07 Nov 2008 03:07:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9050941</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9050941.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9050941</wfw:commentRss><description>&lt;p&gt;There is a very good article on MSDN magazine about security bugs. A good Q&amp;amp;A to determine your security IQ. Check it out at &lt;a title="http://msdn.microsoft.com/en-us/magazine/cc982154.aspx" href="http://msdn.microsoft.com/en-us/magazine/cc982154.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/cc982154.aspx&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;In this spirit I will try to post some security Q&amp;amp;A specially on web and windows applications.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9050941" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category></item><item><title>Security Runtime Engine</title><link>http://blogs.msdn.com/codejunkie/archive/2008/10/24/security-runtime-engine.aspx</link><pubDate>Fri, 24 Oct 2008 20:12:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9015003</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/9015003.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=9015003</wfw:commentRss><description>&lt;p&gt;We have been working on this project for some time now. It is a http module to protect web applications from certain attacks.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogs.msdn.com/cisg/archive/2008/10/24/a-sneak-peak-at-the-security-runtime-engine.aspx" href="http://blogs.msdn.com/cisg/archive/2008/10/24/a-sneak-peak-at-the-security-runtime-engine.aspx"&gt;http://blogs.msdn.com/cisg/archive/2008/10/24/a-sneak-peak-at-the-security-runtime-engine.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Thanks   &lt;br /&gt;RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9015003" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/CISG/default.aspx">CISG</category></item><item><title>System.Security.SecureString in .NET</title><link>http://blogs.msdn.com/codejunkie/archive/2008/10/08/system-security-securestring-in-net.aspx</link><pubDate>Thu, 09 Oct 2008 00:50:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8992102</guid><dc:creator>anilkr</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/8992102.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=8992102</wfw:commentRss><description>&lt;p&gt;Varun in our team has posted part I of series about SecureString in .NET. Awesome blog entry talks about internal details on how secure strings work in .NET with some samples. &lt;/p&gt;  &lt;p&gt;Check it out at &lt;a title="http://blogs.msdn.com/cisg/archive/2008/10/08/secure-strings-in-net-part-i.aspx" href="http://blogs.msdn.com/cisg/archive/2008/10/08/secure-strings-in-net-part-i.aspx"&gt;http://blogs.msdn.com/cisg/archive/2008/10/08/secure-strings-in-net-part-i.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Thanks   &lt;br /&gt;RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8992102" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category></item><item><title>XmlDocument vs XElement Performance</title><link>http://blogs.msdn.com/codejunkie/archive/2008/10/08/xmldocument-vs-xelement-performance.aspx</link><pubDate>Thu, 09 Oct 2008 00:46:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8992094</guid><dc:creator>anilkr</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/8992094.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=8992094</wfw:commentRss><description>&lt;p&gt;I have been using XElement class a lot lately, I was doing some performance tests on this to figure out the difference between this and XmlDocument class and here is what I found.&lt;/p&gt;  &lt;p&gt;First of all XElement class is part of .NET Framework 3.5, it was introduced with XML to Linq and is part of System.Xml.Linq namespace. This class has been totally written from scratch to get better usability with LINQ. XElement.Nodes and XElement.Attribtues return IEnumerable which could be easily used to traverse nodes. You can also use them Lambda expressions. For more information on XML to LINQ check &lt;a title="http://msdn.microsoft.com/en-us/library/bb387098.aspx" href="http://msdn.microsoft.com/en-us/library/bb387098.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb387098.aspx&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;In my case, I have created a test bench (console application) with two static methods, one uses XMLDocument and the other uses XElement to generate XML. The test case is very simple, iterate through the System assembly exported type, construct a giant XML and save it to a stream. Here is the code for both of the static methods.&lt;/p&gt;  &lt;div&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;//Generates XML using XmlDocument&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;internal&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GenerateXmlUsingXmlDocument() &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     MemoryStream ms =&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MemoryStream();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     XmlDocument xmlDoc = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XmlDocument();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration(&lt;span style="color: #006080"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;no&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     XmlElement assembliesNode = xmlDoc.CreateElement(&lt;span style="color: #006080"&gt;&amp;quot;Assemblies&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (Type t &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; Assembly.GetAssembly(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(Object)).GetExportedTypes())&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;         XmlElement assemblyNode = xmlDoc.CreateElement(&lt;span style="color: #006080"&gt;&amp;quot;Assembly&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;         XmlAttribute fullTypeName = xmlDoc.CreateAttribute(&lt;span style="color: #006080"&gt;&amp;quot;FullTypeName&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;         fullTypeName.Value = t.ToString();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;         XmlAttribute isInterfaceName = xmlDoc.CreateAttribute(&lt;span style="color: #006080"&gt;&amp;quot;IsInterface&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;         isInterfaceName.Value = t.IsInterface.ToString();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;         assemblyNode.Attributes.Append(fullTypeName);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;         assemblyNode.Attributes.Append(isInterfaceName);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt;         assembliesNode.AppendChild(assemblyNode);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  19:&lt;/span&gt;     xmlDoc.AppendChild(assembliesNode);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  20:&lt;/span&gt;     xmlDoc.WriteContentTo(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XmlTextWriter(ms,System.Text.ASCIIEncoding.ASCII));&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  21:&lt;/span&gt; }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  22:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  23:&lt;/span&gt; &lt;span style="color: #008000"&gt;//Generates XML using XElement&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  24:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;internal&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GenerateXmlUsingXElement()&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  25:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  26:&lt;/span&gt;     MemoryStream ms = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MemoryStream();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  27:&lt;/span&gt;     XElement assembliesNode = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XElement(&lt;span style="color: #006080"&gt;&amp;quot;Assemblies&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  28:&lt;/span&gt;             from Type t &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; Assembly.GetAssembly(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(Object)).GetExportedTypes()&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  29:&lt;/span&gt;             select &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XElement(&lt;span style="color: #006080"&gt;&amp;quot;Assembly&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  30:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XAttribute(&lt;span style="color: #006080"&gt;&amp;quot;FullTypeName&amp;quot;&lt;/span&gt;, t.ToString()),&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  31:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XAttribute(&lt;span style="color: #006080"&gt;&amp;quot;IsInterface&amp;quot;&lt;/span&gt;, t.IsInterface.ToString())));&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  32:&lt;/span&gt;     &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  33:&lt;/span&gt;     assembliesNode.Save(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XmlTextWriter(ms, System.Text.ASCIIEncoding.ASCII));&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  34:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If you look at the above code, the XElement code is small and uses LINQ expressions for generating XML. By using the following code, I repeatedly test the amount of time it takes for each method to execute.&lt;/p&gt;

&lt;div&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; Stopwatch sw = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Stopwatch();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; index = 0; index &amp;lt; 51; index++)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     sw.Reset(); sw.Start();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     Program.GenerateXmlUsingXmlDocument();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     sw.Stop();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     Console.Write(&lt;span style="color: #006080"&gt;&amp;quot;Generation time using XmlDocument &amp;quot;&lt;/span&gt; +&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;         &lt;span style="color: #006080"&gt;&amp;quot;and XElement: &amp;quot;&lt;/span&gt; + sw.ElapsedMilliseconds);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     sw.Reset(); sw.Start();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     Program.GenerateXmlUsingXElement();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     sw.Stop();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;     Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot; : &amp;quot;&lt;/span&gt; + sw.ElapsedMilliseconds);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//Forcing the Garbage Collector to run to make sure,&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//We dispose of all the types we created on the&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//Managed heap.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;     GC.Collect();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt; }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt; Console.ReadKey();&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;From the above code, you can see that I am testing each method for 50 times. Additionally, after each test, I explicitly call Garbage Collector to clean up objects created by two methods. Now Here is the screen shot of the output. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/codejunkie/WindowsLiveWriter/XmlDocumentvsXElementPerformance_C288/XmlDocumentXElement_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="271" alt="XmlDocumentXElement" src="http://blogs.msdn.com/blogfiles/codejunkie/WindowsLiveWriter/XmlDocumentvsXElementPerformance_C288/XmlDocumentXElement_thumb.png" width="443" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;You can see very clearly, the huge difference in the time it takes to create XML. The difference seems to vary from 6x to 10x times. Specially, this is very important in ASP.NET applications and Web Services where every millisecond counts. One more thing to note that XElement is part of System.Xml.Linq.dll which is part of .NET Framework 3.5, but still uses .NET 2.0 CLR, thus technically you can use a local copy of System.Xml.Linq.dll within your application in cases where you are missing .NET 3.5. But, you will loose all goodness of updations and service packs by the .NET team.&lt;/p&gt;

&lt;p&gt;Thanks
  &lt;br /&gt;Anil RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8992094" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/LINQ/default.aspx">LINQ</category></item><item><title>AntiXss Encoding and ASP.NET Data Binding</title><link>http://blogs.msdn.com/codejunkie/archive/2008/10/01/antixss-encoding-and-asp-net-data-binding.aspx</link><pubDate>Wed, 01 Oct 2008 21:23:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8972011</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/8972011.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=8972011</wfw:commentRss><description>&lt;p&gt;It's been a while since I posted my last blog entry. This time it is on few ASP.NET data binding scenarios and how you should use AntiXss encoding. Very important for ASP.NET developers. Check it out on our team blog at &lt;a title="http://blogs.msdn.com/cisg/archive/2008/10/01/asp-net-data-binding-and-antixss-encoding.aspx" href="http://blogs.msdn.com/cisg/archive/2008/10/01/asp-net-data-binding-and-antixss-encoding.aspx"&gt;http://blogs.msdn.com/cisg/archive/2008/10/01/asp-net-data-binding-and-antixss-encoding.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Anil RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8972011" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/CISG/default.aspx">CISG</category></item><item><title>HTML Encoding of ASP.NET Controls</title><link>http://blogs.msdn.com/codejunkie/archive/2008/09/17/html-encoding-of-asp-net-controls.aspx</link><pubDate>Wed, 17 Sep 2008 20:43:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8955896</guid><dc:creator>anilkr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/codejunkie/comments/8955896.aspx</comments><wfw:commentRss>http://blogs.msdn.com/codejunkie/commentrss.aspx?PostID=8955896</wfw:commentRss><description>&lt;p&gt;Ever wonder which controls need HTML encoding, this is a developer nightmare. We have looked at some common controls that most of developers use and determined which properties need HTML encoding. &lt;/p&gt;  &lt;p&gt;I have posted the blog entry on our team site, check it out at &lt;a title="http://blogs.msdn.com/cisg/archive/2008/09/17/which-asp-net-controls-need-html-encoding.aspx" href="http://blogs.msdn.com/cisg/archive/2008/09/17/which-asp-net-controls-need-html-encoding.aspx"&gt;http://blogs.msdn.com/cisg/archive/2008/09/17/which-asp-net-controls-need-html-encoding.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Thanks   &lt;br /&gt;RV&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8955896" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/codejunkie/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/codejunkie/archive/tags/CISG/default.aspx">CISG</category></item></channel></rss>