<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-15660375</id><updated>2012-01-22T10:46:00.995-08:00</updated><title type='text'>DotNetDubai</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ahsan</name><uri>http://www.blogger.com/profile/12740497037200673524</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>18</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-15660375.post-113381701738476555</id><published>2005-12-05T13:07:00.000-08:00</published><updated>2005-12-08T01:36:25.433-08:00</updated><title type='text'>Regular Expressions in .Net</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="" lang="EN-US"&gt;Regular Expressions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Regular expressions have been widely popular in languages such as PERL and AWK and have been utilized for pattern matching, text manipulation and text searching. These languages are specifically is known for its advanced pattern matching features. Dot Net regular expressions are based on that of Perl and are compatible with Perl 5 regular expressions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;To begin with, they are not as complex as they look, especially if you start experimenting with them. I would recommend that you download a tool such as Expresso (http://www.ultrapico.com/), to become familiar with regular expressions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="" lang="EN-US"&gt;Regular Expression Elements&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Some of the commonly used regular expression elements are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;div align="center"&gt;  &lt;table class="MsoTableGrid" style="width: 100%; margin-left: 12.95pt; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0" width="559"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 22%;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;^&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 78%;" valign="top"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Matches   start of input&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;$&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Matches   end of input&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Matches   any character except new line&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;|&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;OR&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match the   preceding expression 0 or more number of times&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;+&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match the   preceding expression 1 or more number of times&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match the   preceding expression 0 or 1 number of times&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Logical   group / sub-expression (capture as auto number group)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;(?&lt;name&gt;(exp))&lt;o:p&gt;&lt;/o:p&gt;&lt;/name&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Named   capture group&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;(?=exp)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   position preceding a suffix exp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;(?&lt;=exp)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   position following a prefix exp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;(?!exp)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   position after which exp is not found&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;(?&lt;!--exp)&lt;o:p--&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   position before which exp is not found&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;[…]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;List of   characters to match&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;[^expression]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Not   containing any of the specified character&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;{n} or   {n. m}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Quantifier   (Match exact number or range of instances)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;(?(exp   (yes|no))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;If   expression (exp) is true match yes part else no part&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Escape   character (to match any of the special characters)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\w&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   word character&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\W&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   non-word character&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\s&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   white space character&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\S&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   non-white space character&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\d&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   numeric digit&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\D&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match any   numeric digit&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\b&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match a   backspace if in character matching mode ([]).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Otherwise   match the position at beginning or end of a word&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\t&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match tab&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\r&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match   carriage return&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 94.7pt;" valign="top" width="126"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;\n&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 324.9pt;" valign="top" width="433"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Match   line feed&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;    &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;The following are matching substitutions:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div align="center"&gt;  &lt;table class="MsoTableGrid" style="width: 100%; margin-left: 16.6pt; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 22%;" valign="top"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;num&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 78%;" valign="top"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Substitute   last substring matched by group number num&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 93.45pt;" valign="top" width="125"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;${name}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 327.35pt;" valign="top" width="436"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Substitute   last substring matched by group name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 93.45pt;" valign="top" width="125"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;$&amp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 327.35pt;" valign="top" width="436"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Substitute   a copy of entire text itself&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 93.45pt;" valign="top" width="125"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;$`&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 327.35pt;" valign="top" width="436"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Substitute   all the text of the input string before match&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 93.45pt;" valign="top" width="125"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;$’&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 327.35pt;" valign="top" width="436"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Substitute   all the text of the input string after match&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 93.45pt;" valign="top" width="125"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;$+&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 327.35pt;" valign="top" width="436"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Substitute   last matched group&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 93.45pt;" valign="top" width="125"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;$_&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 327.35pt;" valign="top" width="436"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Substitute   input string&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 93.45pt;" valign="top" width="125"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;$$&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 327.35pt;" valign="top" width="436"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Substitute   literal $&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;    &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;Regular expressions could also be used to find repeating patterns by making use of backreferencing, using which you can name a pattern found and then use that reference elsewhere in expression. This naming of patterns is also useful in case we need to parse a string like free form date or time strings.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;span style="" lang="EN-US"&gt;Some Example Regular Expressions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang="EN-US" style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;span style="" lang="EN-US"&gt;Match a word - \btest\b&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang="EN-US" style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;span style="" lang="EN-US"&gt;Match all 6 letter words - \b\w{6}\b&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span dir="ltr"&gt;&lt;span style="" lang="EN-US"&gt;Match all 6 digit numbers - \b\d{6}\b&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;&lt;span style="" lang="EN-US"&gt;Match any number \b\d+\b&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;          &lt;p class="MyBodyBulleted" style="margin-left: 0in; text-indent: 0in;"&gt;&lt;span style="" lang="EN-US"&gt;Instead of giving loads of examples here, I suggest that you download Expresso and check its analyzer view for detailed analysis of the regular expression.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="" lang="EN-US"&gt;Regular Expressions in .Net&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;As already discussed, .Net regular expressions are based on that of Perl and are compatible with Perl 5 regular expressions. Dotnet contains a set of powerful classes that makes it even easier to use regular expressions. The classes are available in the System.Text.RegularExpressions namespace. &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;span style="" lang="EN-US"&gt;How to validate an input string in .Net&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang="EN-US" style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;&lt;span style="" lang="EN-US"&gt;Create a &lt;/span&gt;Regex object ‘RegexObj’&lt;/span&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang="EN-US" style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;Call RegexObj.IsMatch (subjectString ), which will return a Boolean showing validity of input string&lt;/span&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;      &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="" lang="EN-US"&gt;How to perform regular expression substitution (search and replace) in .Net&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang="EN-US" style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;&lt;span style="" lang="EN-US"&gt;Create a &lt;/span&gt;Regex object ‘RegexObj’&lt;/span&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang="EN-US" style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;Call RegexObj.Replace ( subjectString, replaceString ), which will return a Boolean showing validity of input string&lt;/span&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;      &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;How to parse an input string in .Net&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang="EN-US" style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;&lt;span style="" lang="EN-US"&gt;Create a &lt;/span&gt;Regex object ‘RegexObj’, make sure to name the expressions&lt;/span&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang="EN-US" style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;Call RegexObj.Match ( subjectString ), which will return a list of matches in the input string as per the match regular expression&lt;/span&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang="EN-US" style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;Iterate through the matches to perform post parsing &lt;/span&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;        &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt; &lt;/o:p&gt;Free form time parsing function in DotNet&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;table class="MsoTableGrid" style="border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr style=""&gt;&lt;td style="padding: 0in 5.4pt; width: 426.1pt;" valign="top" width="568"&gt;For an example, I have developed a simple free format time parser. I have provided the code and details in this &lt;a href="http://www.codeproject.com/useritems/regex_dotnet.asp"&gt;code project article&lt;/a&gt;.&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="" lang="EN-US"&gt;References and Further &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span class="comment"&gt;&lt;span style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;&lt;span class="comment"&gt;&lt;a href="http://geekswithblogs.net/brcraju/articles/235.aspx"&gt;Learn how to write a Regular Expression&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;&lt;span style="" lang="EN-US"&gt;&lt;a href="http://www.ultrapico.com/"&gt;Ultra Pico – Expresso&lt;/a&gt; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;&lt;span style="" lang="EN-US"&gt;&lt;a href="http://www.codeproject.com/dotnet/RegexTutorial.asp"&gt;The 30 minute Regex Tutorial&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span class="comment"&gt;&lt;span style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir="ltr"&gt;&lt;span class="comment"&gt;&lt;a href="http://www.boyzoid.com/regex/REgEx_cheatSheet.doc"&gt;Regular Expression Cheat Sheet&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span dir="ltr"&gt;&lt;span class="comment"&gt;&lt;a href="ms-help://MS.MSDNQTR.2005JAN.1033/cpguide/html/cpconcomregularexpressions.htm"&gt;.Net Framework Regular Expressions (MSDN Library)&lt;/a&gt; (&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcomregularexpressions.asp"&gt;Online&lt;/a&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span dir="ltr"&gt;&lt;span class="comment"&gt;&lt;a href="http://www.codeproject.com/useritems/regex_dotnet.asp"&gt;http://www.codeproject.com/useritems/regex_dotnet.asp&lt;/a&gt;&lt;br /&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-113381701738476555?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/113381701738476555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=113381701738476555' title='50 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/113381701738476555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/113381701738476555'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/12/regular-expressions-in-net_05.html' title='Regular Expressions in .Net'/><author><name>Ovais Khan</name><uri>http://www.blogger.com/profile/11979634104733335217</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>50</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-113378096636610616</id><published>2005-12-05T03:08:00.000-08:00</published><updated>2005-12-05T03:09:26.506-08:00</updated><title type='text'>Security Practices: ASP.NET 2.0 Security Practices at a Glance</title><content type='html'>Summary&lt;br /&gt;This module presents a set of consolidated practices designed to address ASP.NET version 2.0 security issues. The answers and recommendations presented in this module are designed to supplement the companion modules and additional guidance. The practices are organized by various categories that represent those areas where mistakes are most often made. This module includes an index of practices.&lt;br /&gt;Contents&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_howtousethismodule" target="_self"&gt;How to Use This Module&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_whatsnew" target="_self"&gt;What's New in 2.0&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_indexofpractices" target="_self"&gt;Index of Practices&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_auditingandlogging" target="_self"&gt;Auditing and Logging&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authentication" target="_self"&gt;Authentication&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorization" target="_self"&gt;Authorization&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_codeaccesssecurity" target="_self"&gt;Code Access Security&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_configuration" target="_self"&gt;Configuration&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_dataaccess" target="_self"&gt;Data Access&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_exceptionmanagement" target="_self"&gt;Exception Management&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_impersonation" target="_self"&gt;Impersonation and Delegation&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_inputanddatavalidation" target="_self"&gt;Input and Data Validation&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_securecommunicatioin" target="_self"&gt;Secure Communication&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_sensitivedata" target="_self"&gt;Sensitive Data&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_companionguidance" target="_self"&gt;Companion Guidance&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_additionalresources" target="_self"&gt;Additional Resources&lt;/a&gt;&lt;br /&gt;&lt;a name="pagpractices0001_howtousethismodule"&gt;&lt;/a&gt;How to Use This Module&lt;br /&gt;To get the most from this module:&lt;br /&gt;Use the index to browse the practices. Scan across the practices and quickly jump to a specific practice.&lt;br /&gt;Learn the practices. Learn the key items, terms, and relationships among the various practices.&lt;br /&gt;Use the companion guidance for further details. The referenced How To modules and guideline modules can be used to obtain further details and step-by-step instructions to help you implement solutions.&lt;br /&gt;&lt;a name="pagpractices0001_whatsnew"&gt;&lt;/a&gt;What's New in 2.0&lt;br /&gt;The .NET Framework version 2.0 and ASP.NET version 2.0 introduce many new security features. The most notable enhancements for ASP.NET Web applications are:&lt;br /&gt;Forms authentication and membership. You can now use forms authentication with the new membership feature and membership API. The membership feature supports a provider model, with the SqlMembershipProvider for SQL Server databases and ActiveDirectoryMembershipProvider for Active Directory and Active Directory Application Mode (ADAM) stores provided as built-in providers. You can also create custom providers for your custom user stores. You no longer have to create your own custom databases and write your own custom authentication code.&lt;br /&gt;Role manager. The new role management feature provides secure role storage and an API for managing and checking role membership. The role manager supports a provider model. The supplied providers are:&lt;br /&gt;The SqlRoleProvider for SQL Server role stores.&lt;br /&gt;The WindowsTokenRoleProvider used with Windows authentication, which uses Windows groups as roles.&lt;br /&gt;The AuthorizationStoreRoleProvider, which uses Windows Server 2003 Authorization Manager for managing roles in Active Directory or ADAM.&lt;br /&gt;DPAPI managed wrapper. The .NET Framework version 2.0 provides a set of managed classes to access the Win32 Data Protection API (DPAPI). Code requires the DataProtectionPermission to be able to use DPAPI.&lt;br /&gt;Configuration file changes. Machine-wide configuration settings for all Web applications on a server are now maintained in a machine-level Web.config file instead of Machine.config. The machine-level Web.config file is located in the \Windows\Microsoft.NET\Framework\{version}\CONFIG directory.&lt;br /&gt;Configuration file encryption. ASP.NET version 2.0 introduces a Protected Configuration feature to enable you to encrypt sections of your Machine.config and Web.config files by using either DPAPI or RSA encryption. This is particularly useful for encrypting connection strings and account credentials.&lt;br /&gt;Health monitoring. ASP.NET version 2.0 introduces a health monitoring system. It supports many standard events that you can use to monitor the health of your application. Examples of security-related events that are automatically generated include logon failures and successes when using the ASP.NET membership system, attempts to tamper with or reuse forms authentication tickets, and infrastructure events such as disk access failures. You can also create custom events to instrument your application for other security and non-security related notable events.&lt;br /&gt;Code access security. The SQL Server managed data provider no longer demands Full trust. This means that Medium trust Web applications can now access SQL Server databases by using this provider. Also, in version 2.0, SmtpPermission is available at Full, High, and Medium trust levels. This allows partial trust Web applications to send e-mail.&lt;br /&gt;Machine key enhancements. The &lt;machinekey&gt;now supports a decryption attribute that specifies the symmetric encryption algorithm used to encrypt and decrypt forms authentication tickets. ASP.NET version 2.0 provides support for AES symmetric encryption, which is used by default, in addition to DES and 3DES.&lt;br /&gt;&lt;a name="pagpractices0001_indexofpractices"&gt;&lt;/a&gt;Index of Practices&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_auditingandlogging" target="_self"&gt;Auditing and Logging&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_audithowtousehealthmonitoring" target="_self"&gt;How to use health monitoring in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_audithowtowritetotheeventlog" target="_self"&gt;How to write to the event log&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authentication" target="_self"&gt;Authentication&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtochoosebetweenwindows" target="_self"&gt;How to choose between Windows authentication and forms authentication&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtousewindowsauthenticationinaspnet" target="_self"&gt;How to use Windows authentication in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtousekerberosauthenticationinaspnet" target="_self"&gt;How to use Kerberos authentication in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtouseformsauthenticationinaspnet" target="_self"&gt;How to use forms authentication in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtoprotectformsauthentication" target="_self"&gt;How to protect forms authentication&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtousemembershipinaspnet20" target="_self"&gt;How to use membership in ASP.NET 2.0&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtouseformsauthenticationwithsqlserver" target="_self"&gt;How to use forms authentication with SQL Server&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtouseformsauthenticationwithactivedirectory" target="_self"&gt;How to use forms authentication with Active Directory&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtouseformsauthenticationwithactivedirectoryinmultipledomains" target="_self"&gt;How to use forms authentication with Active Directory in multiple domains&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtoenforcestrongpasswordsusingmembership" target="_self"&gt;How to enforce strong passwords using membership&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtoconfigureaccountlockoutusingmembership" target="_self"&gt;How to configure account lockout using membership&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authhowtoenablepasswordresetusingactivedirectorymembershipprovider" target="_self"&gt;How to enable password reset using ActiveDirectoryMembershipProvider&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorization" target="_self"&gt;Authorization&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtoperformauthorizationinaspnet" target="_self"&gt;How to perform authorization in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtoperformrolebasedauthorizationincode" target="_self"&gt;How to perform role-based authorization in code&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtouserolemanagerinaspnet" target="_self"&gt;How to use role manager in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtousewindowsgroupsforroleauthorization" target="_self"&gt;How to use Windows groups for role authorization&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtouseauthorizationmanagerinaspnet" target="_self"&gt;How to use Authorization Manager in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtocacherolesinaspnet" target="_self"&gt;How to cache roles in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtoconfigureurlauthorizationinwebconfig" target="_self"&gt;How to configure URL authorization in Web.config&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtolockauthorizationsettings" target="_self"&gt;How to lock authorization settings&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_codeaccesssecurity" target="_self"&gt;Code Access Security&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_codehowtousecodeaccesssecurityinaspnet" target="_self"&gt;How to use code access security in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_codehowtousecustomtrustlevelswithcodeaccesssecurityinaspnet" target="_self"&gt;How to use custom trust levels with code access security in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_codehowtoruninmediumtrust" target="_self"&gt;How to run in Medium trust&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_configuration" target="_self"&gt;Configuration&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtoencryptsensitivedatainmachineconfigandwebconfig" target="_self"&gt;How to encrypt sensitive data in Machine.config and Web.config&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtochoosebetweenmachineanduserkeystorage" target="_self"&gt;How to choose between machine and user key storage&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtousedpapiwithauserstoretoencryptaconnectionstringinwebconfig" target="_self"&gt;How to use DPAPI with a user store to encrypt a connection string in Web.config&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtousersawithauserlevelkeycontainertoencryptaconnectionstringinwebconfig" target="_self"&gt;How to use RSA with a user-level key container to encrypt a connection string in Web.config&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtorunanaspnetapplicationwithaparticularidentity" target="_self"&gt;How to run an ASP.NET application with a particular identity&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtocreateaserviceaccountforaspnet" target="_self"&gt;How to create a service account for ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtoconfigurethemachinekeyinwebfarms" target="_self"&gt;How to configure the machine key in Web farms&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtolockconfigurationsettings" target="_self"&gt;How to lock configuration settings&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_dataaccess" target="_self"&gt;Data Access&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_datahowtoprotectdatabaseconnectionstrings" target="_self"&gt;How to protect database connection strings&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_datahowtoaccessadatabasefromaspnet" target="_self"&gt;How to access a database from ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_datahowtousewindowsauthenticationtoconnecttosqlserver" target="_self"&gt;How to use Windows authentication to connect to SQL Server&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_datahowtoaccesssqlserverbyusingsqlauthentication" target="_self"&gt;How to access SQL Server by using SQL authentication&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_datahowtousethenetworkserviceaccounttoconnecttosqlserver" target="_self"&gt;How to use the Network Service account to connect to SQL Server&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_datahowtopreventsqlinjection" target="_self"&gt;How to prevent SQL injection&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_exceptionmanagement" target="_self"&gt;Exception Management&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_exchowtohandleexceptionssecurely" target="_self"&gt;How to handle exceptions securely&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_exchowtopreventdetailederrorsfromreturningtotheclient" target="_self"&gt;How to prevent detailed errors from returning to the client&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_exchowtousestructuredexceptionhandling" target="_self"&gt;How to use structured exception handling&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_exchowtocreateaglobalerrorhandlerforyourapplication" target="_self"&gt;How to create a global error handler for your application&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_exchowtospecifyadefaulterrorpage" target="_self"&gt;How to specify a default error page&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_impersonation" target="_self"&gt;Impersonation and Delegation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_imphowtochoosebetweentrustedsubsystemandimpersonationdelegation" target="_self"&gt;How to choose between trusted subsystem and impersonation/delegation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_imphowtoimpersonatetheoriginalcaller" target="_self"&gt;How to impersonate the original caller&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_imphowtotemporarilyimpersonatetheoriginalcaller" target="_self"&gt;How to temporarily impersonate the original caller&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_imphowtouseprotocoltransitionandconstraineddelegationinaspnet" target="_self"&gt;How to use protocol transition and constrained delegation in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_inputanddatavalidation" target="_self"&gt;Input and Data Validation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_inputhowtovalidateinputinaspnet" target="_self"&gt;How to validate input in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_inputhowtovalidateinputinservercontrols" target="_self"&gt;How to validate input in server controls&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_inputhowtovalidateinputinhtmlcontrolsquerystringcookiesandhttpheaders" target="_self"&gt;How to validate input in HTML controls, QueryString, cookies, and HTTP headers&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_inputhowtopreventcrosssitescripting" target="_self"&gt;How to prevent cross site scripting&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_securecommunicatioin" target="_self"&gt;Secure Communication&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_sechowtochoosebetweenipsecandssl" target="_self"&gt;How to choose between IPSec and SSL&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_sechowtosecurecommunicationbetweenbrowserclientsandwebserver" target="_self"&gt;How to secure communication between browser clients and Web server&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_sechowtosecurecommunicationbetweenservers" target="_self"&gt;How to secure communication between servers&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_sensitivedata" target="_self"&gt;Sensitive Data&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_senhowtoprotectsensitivedatainadatabase" target="_self"&gt;How to protect sensitive data in a database&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_senhowtoencryptconfigurationdatainawebfarm" target="_self"&gt;How to encrypt configuration data in a Web farm&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_senhowtoprotectviewstate" target="_self"&gt;How to protect ViewState&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_senhowtoprotectpasswords" target="_self"&gt;How to protect passwords&lt;/a&gt;&lt;br /&gt;&lt;a name="pagpractices0001_auditingandlogging"&gt;&lt;/a&gt;Auditing and Logging&lt;br /&gt;&lt;a name="pagpractices0001_audithowtousehealthmonitoring"&gt;&lt;/a&gt;How to use health monitoring in ASP.NET&lt;br /&gt;You can use the health monitoring feature introduced in ASP.NET version 2.0 to instrument key application events. You can choose where to log events by configuring an appropriate provider. You can instrument built-in events or create custom events by deriving from one of the provided base events to monitor specific business logic or operations in your Web application. By default, health monitoring tracks all Web infrastructure error events (inheriting from System.Web.Management.WebErrorEvent) and all audit failure events (inheriting from System.Web.Management.WebFailureAuditEvent). You need to identify the additional security-related events that you want to instrument.&lt;br /&gt;To configure health monitoring:&lt;br /&gt;In Web.config, configure the events that you want to instrument by using the &lt;eventmappings&gt;element, specifying a user friendly name and type of the event. You can configure event mappings for custom events and for any of the standard events in System.Web.Management, such as WebFailureAuditEvent and WebAuthenticationFailureAuditEvent.&lt;br /&gt;Configure the provider that you want to use as your event sink by using a &lt;providers&gt;element, specifying a user friendly name and type of the provider. Providers are supported for SQL Server, the Windows event log, WMI, e-mail, and trace. You can also create custom providers.&lt;br /&gt;Configure the &lt;profiles&gt;element by specifying the following:&lt;br /&gt;minInstances. This is the minimum occurrences after which the event should be logged.&lt;br /&gt;maxLimit. This is the maximum limit for the occurrences to be logged.&lt;br /&gt;minInterval. This is the minimum interval between which the same event can be logged.&lt;br /&gt;Note that this is optional because you can specify the same information in a &lt;rules&gt;configuration. By using a &lt;profiles&gt;element, you benefit from reuse because you can use the same profile for multiple different rules.&lt;br /&gt;Configure the &lt;rules&gt;element, specifying the event name, the provider name, and the profile name. You can specify the profile to be used or you can configure the profile information for a rule by setting the minInstances, maxLimit and minInterval directly on the &lt;rules&gt;element.&lt;br /&gt;The following configuration file example shows the structure of a typical health monitoring configuration. &lt;configuration&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;.....&lt;br /&gt;&lt;healthmonitoring enabled="truefalse" heartbeatinterval="time interval"&gt;&lt;br /&gt;&lt;buffermodes&gt;... &lt;/buffermodes&gt;&lt;br /&gt;&lt;providers&gt;... &lt;/providers&gt;&lt;br /&gt;&lt;eventmappings&gt;... &lt;/eventmappings&gt;&lt;br /&gt;&lt;profiles&gt;... &lt;/profiles&gt;&lt;br /&gt;&lt;rules&gt;... &lt;/rules&gt;&lt;br /&gt;&lt;/healthmonitoring&gt;&lt;br /&gt;.....&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000011.asp"&gt;How To: Use Health Monitoring in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_audithowtowritetotheeventlog"&gt;&lt;/a&gt;How to write to the event log&lt;br /&gt;By default, ASP.NET applications that run under the default Network Service identity can write to the Windows event log by using an existing event source, but they cannot create new event sources. To create an event source, your ASP.NET account needs permissions to create a new registry entry beneath the following key: HKLM\SYSTEM\CurrentControlSet\Services\Eventlog\.&lt;br /&gt;To enable your ASP.NET application to write to the event log using its own event source, you have two options:&lt;br /&gt;Grant your ASP.NET process account (or impersonated identity if your application uses impersonation) permissions on the following registry key: HKLM\SYSTEM\CurrentControlSet\Services\Eventlog\.&lt;br /&gt;Create the event source at application install time when administrator privileges are available. You can use a .NET installer class, which can be instantiated by the Windows Installer (if you are using .msi deployment) or by the InstallUtil.exe system utility.&lt;br /&gt;Note When you use the event log provider with ASP.NET health monitoring, events are logged by using an event source named "ASP.NET xxxxxx" where xxxxxx represents the .NET Framework version number. This event source is created when you install the .NET Framework. This is not configurable and you cannot change the event source used by health monitoring events.&lt;br /&gt;For more information on auditing and logging, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000016.asp"&gt;How To: Instrument ASP.NET 2.0 Applications for Security&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authentication"&gt;&lt;/a&gt;Authentication&lt;br /&gt;&lt;a name="pagpractices0001_authhowtochoosebetweenwindows"&gt;&lt;/a&gt;How to choose between Windows authentication and forms authentication&lt;br /&gt;Use Windows authentication when you can because it provides secure credential management, password policies, and user account management tools.&lt;br /&gt;To choose between Windows authentication and forms authentication:&lt;br /&gt;If your user accounts are in Active Directory or are local accounts, use Windows authentication if you can.&lt;br /&gt;If you cannot use Windows authentication to your Active Directory store, use forms authentication to Active Directory, and use the ActiveDirectoryMembershipProvider.&lt;br /&gt;If your user accounts are in a SQL Server database, use forms authentication to SQL Server, by using the SqlMembershipProvider.&lt;br /&gt;If your user accounts are in ADAM, use forms authentication to ADAM, by using the ActiveDirectoryMembershipProvider.&lt;br /&gt;If your user accounts are in a store other than the previously listed stores, create a custom membership provider and configure forms authentication to use it.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtousewindowsauthenticationinaspnet"&gt;&lt;/a&gt;How to use Windows authentication in ASP.NET&lt;br /&gt;To use Windows authentication in ASP.NET, you must use Microsoft Internet Information Services (IIS) to disable anonymous access and configure a Windows-based authentication method for your Web application's virtual directory. You are generally recommended to use Windows integrated authentication, but you can also use Basic, Digest, or client certificate authentication. You must also ensure that the mode attribute on the &lt;authentication&gt;element is set to "Windows" (the default setting) in your Web.config file.&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000025.asp"&gt;How To: Use Windows Authentication in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtousekerberosauthenticationinaspnet"&gt;&lt;/a&gt;How to use Kerberos authentication in ASP.NET&lt;br /&gt;To use Kerberos authentication to authenticate the end users of your Web application, all computers must be in a Windows Server 2000 or later domain. Your clients must be using Internet Explorer version 5.5 or later. Your application's virtual directory must be configured for Integrated Windows authentication and anonymous access must be disabled. You must set &lt;authentication mode="Windows"&gt;in your Web.config file.&lt;br /&gt;If you run your application using a domain service account, you must register a service principal name (SPN) for that account in Active Directory to associate the account with the HTTP service on the Web server. To register an SPN, use the Setspn.exe utility as follows:&lt;br /&gt;setspn -A HTTP/webservername domain\customAccountName&lt;br /&gt;setspn -A HTTP/webservername.fullyqualifieddomainname domain\customAccountName&lt;br /&gt;Note that you cannot have multiple Web applications with the same host name if you want them to have multiple identities and to use Kerberos authentication. This is an HTTP limitation, not a Kerberos limitation. The workaround is to have multiple Domain Name System (DNS) names for the same host, and start the URLs for each Web application with a different DNS name. For example, you would use http://app1 and http://app2 instead of http://site/app1 and http://site/app2.&lt;br /&gt;Note: By default, Integrated Windows authentication is not enabled in Internet Explorer 6.&lt;br /&gt;If your clients run Internet Explorer 6, you must enable the browser to respond to a negotiate challenge and perform Kerberos authentication. To do this, select the Enable Integrated Windows Authentication check box in the Security section of the Advanced tab of the Internet Options menu, and then restart the browser. Administrators can enable Integrated Windows authentication by setting the EnableNegotiate DWORD value to 1 in the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings&lt;br /&gt;&lt;a name="pagpractices0001_authhowtouseformsauthenticationinaspnet"&gt;&lt;/a&gt;How to use forms authentication in ASP.NET&lt;br /&gt;In the machine-level Web.config file or your application's Web.config file, set the mode attribute on the &lt;authentication&gt;element to "Forms". In IIS, ensure that your Web site is configured for anonymous access. Deny unauthenticated users access to your Web site by configuring URL authorization. To do this, create an &lt;authorization&gt;element in Web.config with &lt;deny users="?"&gt;.&lt;br /&gt;ASP.NET 2.0 introduces the membership feature. This feature simplifies forms authentication and reduces the amount of code you need to write. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000022.asp"&gt;How to Use Membership in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtoprotectformsauthentication"&gt;&lt;/a&gt;How to protect forms authentication&lt;br /&gt;Use Secure Sockets Layer (SSL) to protect the forms authentication credentials and the forms authentication cookie passed from browser to server. Ensure that the authentication cookie is passed only over HTTPS connections. Encrypt and integrity check the authentication cookie, do not persist it on the client computer, and do not use it for personalization purposes; use a separate cookie for personalization. Set the httpOnly cookie attribute to protect cookie information being accessed by client script. A secure &lt;forms&gt;element configuration is shown here. &lt;forms path="/Secure" name="YourAppName" timeout="00:30:00" protection="All" loginurl="Secure\Login.aspx" requiressl="true" slidingexpiration="true"&gt;&lt;br /&gt;&lt;br /&gt;For new site designs, consider creating a separate subfolder for those pages that require authenticated and SSL-based access. If you cannot use SSL, consider reducing the cookie lifetime by reducing the timeout value to minimize the time window within which an attacker can use a captured authentication cookie to access your site. If you are in a scenario where you are concerned about cookie hijacking, consider reducing the timeout and setting slidingExpiration="false". If sliding expiration is turned off, the authentication cookie expires after the time out period irrespective of whether or not the user is active. After the timeout period, the user must re-authenticate.&lt;br /&gt;Also ensure that your credential management is secure. Enforce strong passwords and protect your authentication login form against SQL injection attacks by validating and constraining input credentials, and by using parameterized stored procedures while accessing the user store. Secure the connection string that points to your user store for example by encrypting the connectionStrings section in your Web.config file. Do not store plaintext or encrypted passwords in your user store. Store non-reversible password hashes instead. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000012.asp"&gt;How To: Protect Forms Authentication in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtousemembershipinaspnet20"&gt;&lt;/a&gt;How to use membership in ASP.NET 2.0&lt;br /&gt;To configure membership, you need to define a connection string to point to the provider store and configure your provider definition in the Web.config file.&lt;br /&gt;To configure membership:&lt;br /&gt;Configure your application for forms authentication by setting &lt;authentication mode="Forms"&gt;&lt;br /&gt;Add a connection string to the &lt;connectionstrings&gt;section to point to your user store. If you are using the ActiveDirectoryMembershipProvider, this is a Lightweight Directory Access Protocol (LDAP) query string pointing to your user container in Active Directory or ADAM. If you are using the SqlMembershipProvider, this is a database connection string that points to your user store database.&lt;br /&gt;Add a &lt;membership&gt;section to configure your chosen membership provider.&lt;br /&gt;Configure the specific provider by creating a &lt;providers&gt;section beneath the &lt;membership&gt;element in your application's Web.config. The membership system supports a number of different providers:&lt;br /&gt;If your user accounts are in Active Directory or ADAM, use the ActiveDirectoryMembershipProvider.&lt;br /&gt;If your user accounts are in SQL Server, use SqlMembershipProvider.&lt;br /&gt;If your user accounts are in a store other than those previously listed, create a custom membership provider by inheriting from the MembershipProvider base class.&lt;br /&gt;Set the defaultProvider attribute on the &lt;membership&gt;element to your chosen provider.&lt;br /&gt;To validate and manage users, use the Membership API (for example, Membership.CreateUser and Membership.ValidateUser) or use the Login controls, which automatically use your membership configuration.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtouseformsauthenticationwithsqlserver"&gt;&lt;/a&gt;How to use forms authentication with SQL Server&lt;br /&gt;To use forms authentication against a SQL Server user store, you use the SqlMembershipProvider.&lt;br /&gt;To use this provider:&lt;br /&gt;Create the membership SQL Server database by using the Aspnet_regsql tool.&lt;br /&gt;Create a SQL Server login for your ASP.NET application's process identity (or impersonated identity if your application uses impersonation) and grant it the appropriate permissions in the membership database.&lt;br /&gt;Establish a connection string in Web.config that points to the membership database.&lt;br /&gt;Configure the &lt;membership&gt;element in Web.config for SqlMembershipProvider, specifying at least the connection string name and an application name. The membership system subdivides the membership database by application name.&lt;br /&gt;Set the defaultProvider attribute on &lt;membership&gt;element to the configured provider name.&lt;br /&gt;Configure password complexity rules if you need to override the defaults, which ensure a minimum length of 7 characters with one of them being non-alphanumeric.&lt;br /&gt;A typical SQLMembershipProvider configuration is shown here. &lt;connectionstrings&gt;&lt;br /&gt;&lt;add name="MySqlConnection" connectionstring="Server=MySqlServer; Database=aspnetdb; Trusted_Connection=yes;"&gt;&lt;br /&gt;&lt;/connectionstrings&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;...&lt;br /&gt;&lt;membership userisonlinetimewindow="15" defaultprovider="SqlProvider"&gt;&lt;br /&gt;&lt;providers&gt;&lt;br /&gt;&lt;clear&gt;&lt;br /&gt;&lt;add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionstringname="MySqlConnection" applicationname="MyApplication" enablepasswordretrieval="false" enablepasswordreset="true" requiresquestionandanswer="true" requiresuniqueemail="true" passwordformat="Hashed"&gt;&lt;br /&gt;&lt;/providers&gt;&lt;br /&gt;&lt;/membership&gt;&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000014.asp"&gt;How To: Use Forms Authentication with SQL Server in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtouseformsauthenticationwithactivedirectory"&gt;&lt;/a&gt;How to use forms authentication with Active Directory&lt;br /&gt;To use forms authentication with Active Directory, you use the ActiveDirectoryMembershipProvider.&lt;br /&gt;To use this provider:&lt;br /&gt;Configure a connection string in Web.config that contains an LDAP query string that points to your user's container in Active Directory.&lt;br /&gt;Configure the &lt;membership&gt;element in your Web.config file for ActiveDirectoryMembershipProvider specifying at least the connection string name and optionally the credentials of an account capable of accessing Active Directory with the necessary permissions. If you do not specify account credentials, your application's process identity is used to access Active Directory, regardless of whether your application uses impersonation. Either the account specified in the Web.config file or your process account must have the appropriate permissions to access Active Directory.&lt;br /&gt;Set the defaultProvider attribute on &lt;membership&gt;element to the configured provider name.&lt;br /&gt;A typical ActiveDirectoryMembershipProvider configuration is shown here. &lt;connectionstrings&gt;&lt;br /&gt;&lt;add name="ADConnectionString" connectionstring="LDAP://domain.testing.com/CN=Users,DC=domain,DC=testing,DC=com"&gt;&lt;br /&gt;&lt;/connectionstrings&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;...&lt;br /&gt;&lt;membership defaultprovider="MembershipADProvider"&gt;&lt;br /&gt;&lt;providers&gt;&lt;br /&gt;&lt;add name="MembershipADProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionstringname="ADConnectionString" connectionusername=""&gt;\administrator"&gt;connectionPassword="password"/&gt;&lt;br /&gt;&lt;/providers&gt;&lt;br /&gt;&lt;/membership&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000026.asp"&gt;How To: Use Forms Authentication with Active Directory in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtouseformsauthenticationwithactivedirectoryinmultipledomains"&gt;&lt;/a&gt;How to use forms authentication with Active Directory in multiple domains&lt;br /&gt;Create a custom login page by using text boxes and buttons. You cannot use the ASP.NET version 2.0 login controls in a multiple domain scenario.&lt;br /&gt;Configure your application for forms authentication in the Web.config file. &lt;authentication mode="Forms"&gt;&lt;br /&gt;&lt;forms name=".ADAuthCookie" timeout="10"&gt;&lt;br /&gt;&lt;/authentication&gt;&lt;br /&gt;&lt;br /&gt;Deny unauthenticated access to your Web application. &lt;authorization&gt;&lt;br /&gt;&lt;deny users="?"&gt;&lt;br /&gt;&lt;allow users="*"&gt;&lt;br /&gt;&lt;/authorization&gt;&lt;br /&gt;&lt;br /&gt;Add a connection string to point to the relevant users container in the domain controller for each domain. &lt;connectionstrings&gt;&lt;br /&gt;&lt;add name="TestDomain1ConnectionString" connectionstring="LDAP://testdomain1.test.com/CN=Users,DC=testdomain1,DC=test,DC=com"&gt;&lt;br /&gt;&lt;add name="TestDomain2ConnectionString" connectionstring="LDAP://testdomain2.test.com/CN=Users,DC=testdomain2,DC=test,DC=com"&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/connectionstrings&gt;&lt;br /&gt;&lt;br /&gt;Configure the membership element and the ActiveDirectoryMembership providers in the Web.config file to point to each domain. &lt;membership&gt;&lt;br /&gt;&lt;providers&gt;&lt;br /&gt;&lt;add name="TestDomain1ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionstringname="TestDomain1ConnectionString" connectionusername="testdomain1\administrator" connectionpassword="password"&gt;&lt;br /&gt;&lt;add name="TestDomain2ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionstringname="TestDomain2ConnectionString" connectionusername="testdomain2\administrator" connectionpassword="password"&gt;&lt;br /&gt;&lt;/providers&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/membership&gt;&lt;br /&gt;&lt;br /&gt;Note that the preceding example assumes you are working in a test domain and specific credentials are specified to connect to your Active Directory. If you do include credentials, you should encrypt them by using the Aspnet_regiis.exe utility. If you do not specify credentials, your application's process identity is used to connect to Active Directory.&lt;br /&gt;Authenticate users against the appropriate domain controller. You can obtain the domain controller name from the domain component of the supplied user name. The following example assumes that the user supplies a UPN of the form username@domainname.com. string[] partsOfUserName =&lt;br /&gt;UserNameTextBox.Text.Split("@".ToCharArray());&lt;br /&gt;string domainName = partsOfUserName[1];&lt;br /&gt;MembershipProvider domainProvider;&lt;br /&gt;switch (domainName)&lt;br /&gt;{&lt;br /&gt;case "TestDomain1.test.com":&lt;br /&gt;domainProvider = Membership.Providers["TestDomain1ADMembershipProvider"];&lt;br /&gt;break;&lt;br /&gt;case "TestDomain2.test.com":&lt;br /&gt;domainProvider = Membership.Providers["TestDomain2ADMembershipProvider"];&lt;br /&gt;break;&lt;br /&gt;default:&lt;br /&gt;throw(new Exception("This domain is not supported"));&lt;br /&gt;}&lt;br /&gt;if (domainProvider.ValidateUser(UserNameTextBox.Text,&lt;br /&gt;PasswordTextBox.Text))&lt;br /&gt;{&lt;br /&gt;if (Request.QueryString["ReturnUrl"] != null)&lt;br /&gt;{&lt;br /&gt;FormsAuthentication.RedirectFromLoginPage(UserNameTextBox.Text,&lt;br /&gt;false);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;FormsAuthentication.SetAuthCookie(UserNameTextBox.Text, false);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;Response.Write("Invalid UserID and Password");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000021.asp"&gt;How To: Use Forms Authentication with Active Directory in Multiple Domains in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtoenforcestrongpasswordsusingmembership"&gt;&lt;/a&gt;How to enforce strong passwords using membership&lt;br /&gt;You can strengthen user password requirements by configuring the attributes minRequiredPasswordLength, minRequiredNonAlphanumericCharacters, and passwordStrengthRegularExpression on your membership provider configuration.&lt;br /&gt;If you are using the SqlMembershipProvider, the default password strength is set to a minimum password length of 7 characters with at least one non-alphanumeric character.&lt;br /&gt;If you are using the ActiveDirectoryMembershipProvider with Active Directory, your domain password policy is used by default, although you can further strengthen password policy by overriding this with your membership configuration by using the attributes listed earlier. Similarly, if you are using ActiveDirectoryMembershipProvider with ADAM, your local password policy is used, although you can override this with your membership configuration.&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000012.asp"&gt;How To: Protect Forms Authentication in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtoconfigureaccountlockoutusingmembership"&gt;&lt;/a&gt;How to configure account lockout using membership&lt;br /&gt;If you are using the SqlMembershipProvider, you use the maxInvalidPasswordAttempts and passwordAttemptWindows attributes. By default, these values are 5 and 10, respectively. This means you get 5 invalid attempts within 10 minutes before you are locked out.&lt;br /&gt;If you are using the ActiveDirectoryMembershipProvider, your domain or local security policy controls the password lockout. Note that if an account is locked out by the provider, it is not locked out within Active Directory, so you could still log on to Windows with the account. However, the ActiveDirectoryMembershipProvider treats the account as locked out, so the user cannot logon through an application that uses the provider until the lockout duration elapses. Accounts locked out by the provider are re-enabled after a time interval defined by the attributeMapFailedPasswordAnswerLockoutTime attribute. Alternatively, you can write code that calls the UnlockUser method on the MembershipUser object.&lt;br /&gt;&lt;a name="pagpractices0001_authhowtoenablepasswordresetusingactivedirectorymembershipprovider"&gt;&lt;/a&gt;How to enable password reset using ActiveDirectoryMembershipProvider&lt;br /&gt;The ActiveDirectoryMembershipProvider class supports password reset security by requiring the user to answer a question that was provided along with an answer when the account was initially created.&lt;br /&gt;To enable password reset:&lt;br /&gt;Extend your Active Directory schema to add new attributes to the built-in User class. To extend the User class:&lt;br /&gt;Add two single-valued attributes of type string to hold the password question and password answer.&lt;br /&gt;Add three new attributes to store tracking data used to manage account lockout, a single-valued attribute of type integer to track the failed answer count, a single-valued attribute of type Large integer/interval to hold the last time at which an invalid answer was supplied by the user while attempting to reset their password, and a single-valued attribute of type Large integer/interval to hold the time at which the account was locked out because of a succession of bad password answers being provided.&lt;br /&gt;Configure your &lt;membership&gt;element in Web.config for the ActiveDirectoryMembershipProvider. Set enablePasswordReset and requiresQuestionAndAnswer to true. Also set the series of mapping attributes to establish mappings to the extended Active Directory User object attributes that you created. Mapping attributes include attributeMapUsername, attributeMapPasswordQuestion, attributeMapPasswordAnswer, attributeMapFailedPasswordAnswerCount, attributeMapFailedPasswordAnswerTime, and atributeMapFailedPasswordAnswerLockoutTime.&lt;br /&gt;Your provider configuration to support password resets should look similar to the one here. &lt;add name="MyADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionstringname="ADConnectionString" enablepasswordreset="true" requiresquestionandanswer="true" requiresuniqueemail="true" connectionusername="dc\administrator" connectionpassword="P@ssw0rd" attributemapusername="sAMAccountName" attributemappasswordquestion="passwordQuestion" attributemappasswordanswer="passwordAnswer" attributemapfailedpasswordanswercount="badPasswordAnswerCount" attributemapfailedpasswordanswertime="badPasswordAnswerTime" attributemapfailedpasswordanswerlockouttime="badPasswordAnswerLockoutTime"&gt;&lt;br /&gt;&lt;br /&gt;Set the PasswordRecoveryText and PasswordRecoveryURL on your Login control. Set the URL to a page that contains a PasswordRecovery control. If a user has forgotten a password, he or she can click the password recovery text link on the Login control and then enter a user name. The PasswordRecovery control then prompts the user with the predetermined question. On submission of the correct answer, the ActiveDirectoryMembershipProvider resets the user's password to a randomly created password value of an appropriate strength, and then it sends an e-mail message to the user with the new password. The e-mail address is usually supplied during registration.&lt;br /&gt;&lt;a name="pagpractices0001_authorization"&gt;&lt;/a&gt;Authorization&lt;br /&gt;&lt;a name="pagpractices0001_authorhowtoperformauthorizationinaspnet"&gt;&lt;/a&gt;How to perform authorization in ASP.NET&lt;br /&gt;After you authenticate the caller, you can authorize the user prior to performing restricted operations or accessing restricted resources. ASP.NET attaches a User object (which implements an IPrincipal interface) to the current HTTP context (HttpContext.User) and you use that as the basis for your authorization checks. Administrators can configure authorization in Web.config or you can authorize the caller programmatically in code. Authorization options include:&lt;br /&gt;FileAuthorization. For file types mapped by IIS to the ASP.NET ISAPI extension (Aspnet_isapi.dll), automatic access checks are performed using the authenticated user's Windows access token (which may be IUSR_MACHINE for anonymous users) against the access control list (ACL) attached to the requested ASP.NET file. The FileAuthorizationModule class only performs access checks against the requested file. For example, if you request Default.aspx and it contains an embedded user control (Usercontrol.ascx), which in turn includes an image tag (pointing to Image.gif), the FileAuthorizationModule performs an access check for Default.aspx and Usercontrol.ascx, because these file types are mapped by IIS to the ASP.NET ISAPI extension. The FileAuthorizationModule does not perform a check for Image.gif, because this is a static file handled internally by IIS. However, because access checks for static files are performed by IIS, the authenticated user must still be granted read permission to the file with an appropriately configured ACL.&lt;br /&gt;UrlAuthorization. By configuring the &lt;authorization&gt;element in Web.config, administrators can authorize the user held in the HttpContext.User object. You can authorize the user based on the user's name or based on the user's role membership. ASP.NET version 2.0 on Windows Server 2003 protects all files in a directory, even those not mapped to ASP.NET, such as .html, .gif, and .jpg files.&lt;br /&gt;Role checks in code. You can call User.IsInRole or Roles.IsUserInRole methods for fine grained authorization logic in code. Alternatively, you can use PrincipalPermission demands to ensure that the caller is a specific identity or a member of a particular role.&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtoperformrolebasedauthorizationincode" target="_self"&gt;How to perform role-based authorization in code&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtoconfigureurlauthorizationinwebconfig" target="_self"&gt;How to configure URL authorization in Web.config&lt;/a&gt; in this topic.&lt;br /&gt;&lt;a name="pagpractices0001_authorhowtoperformrolebasedauthorizationincode"&gt;&lt;/a&gt;How to perform role-based authorization in code&lt;br /&gt;You can perform role-based authorization in code either by performing explicit role checks (User.IsInRole or Roles.IsUserInRole) or by using PrincipalPermission demands. You can do the latter either imperatively in the body of a method or declaratively by adding attributes to your classes and methods. You often need to perform role-based authorization in code when you need additional run-time variables to be able to construct the required authorization logic. For example, authorization might be dependent on a user being a member of the Manager role and a transaction amount not exceeding a particular limit.&lt;br /&gt;To use explicit role checks:&lt;br /&gt;Use the IPrincipal interface of the user object attached to the current HTTP request. This approach works with ASP.NET versions 1.0, 1.1 and 2.0. if(User.IsInRole("Manager"))&lt;br /&gt;// Perform restricted operation&lt;br /&gt;else&lt;br /&gt;// Return unauthorized access error&lt;br /&gt;&lt;br /&gt;Alternatively, use Role Manager APIs introduced in ASP.NET version 2.0, which support a similar Roles.IsUserInRole method, as shown here. if(Roles.IsUserInRole("Manager"))&lt;br /&gt;// Perform restricted operation&lt;br /&gt;else&lt;br /&gt;// Return unauthorized access error&lt;br /&gt;&lt;br /&gt;The preceding code tests whether the currently authenticated user is a member of a particular role. You can also test whether any given user is a member of a role, as follows. if(Roles.IsUserInRole("Bob", "Manager"))&lt;br /&gt;// Perform restricted operation&lt;br /&gt;else&lt;br /&gt;// Return unauthorized access error&lt;br /&gt;&lt;br /&gt;Note To use the Role Manager API, you must enable the role manager feature and configure an appropriate role store. The following Web.config file configuration enables role manager and uses the built-in WindowsTokenRoleProvider. This provider is for use with Windows authentication, where Windows groups are used as roles. &lt;rolemanager defaultprovider="AspNetWindowsTokenRoleProvider" enabled="true"&gt;&lt;br /&gt;&lt;br /&gt;To use PrincipalPermission demands:&lt;br /&gt;Construct a PrincipalPermission object and call its Demand method to perform authorization.&lt;br /&gt;For fine grained authorization, call PrincipalPermission.Demand within code as shown here. // Imperative checks&lt;br /&gt;PrincipalPermission permCheckUser = new PrincipalPermission("Bob", null);&lt;br /&gt;permCheckUser.Demand();&lt;br /&gt;&lt;br /&gt;Alternatively, you can decorate your classes or methods with the PrincipalPermissionAttribute as shown here. [PrincipalPermission(SecurityAction.Demand, Role="Manager")]&lt;br /&gt;&lt;br /&gt;The advantage of this approach is that the security requirements of your methods are visible to tools such as Permview.exe.&lt;br /&gt;&lt;a name="pagpractices0001_authorhowtouserolemanagerinaspnet"&gt;&lt;/a&gt;How to use role manager in ASP.NET&lt;br /&gt;Role manager is new feature introduced in ASP.NET 2.0 for role-based authorization.&lt;br /&gt;To use the role manager feature in an ASP.NET application, you need to do the following:&lt;br /&gt;Add a &lt;rolemanager&gt;element beneath the &lt;system.web&gt;section of your application's Web.config file and enable role manager by setting its enabled attribute to true.&lt;br /&gt;Add a connection string to the &lt;connectionstrings&gt;section to point to your roles store. If you are using the AuthorizationStoreRoleProvider, this is an LDAP query string pointing to your Authorization Manager Policy store in Active Directory or ADAM. If you are using the SqlRoleProvider, this is a database connection string that points to your role store database.&lt;br /&gt;Configure the specific provider in the &lt;rolemanager&gt;element in your application's Web.config file. The role manager system supports the following providers:&lt;br /&gt;If your application roles are in an Authorization Manager Policy store in Active Directory or ADAM, use the AuthorizationStoreRoleProvider.&lt;br /&gt;If your application roles are in a SQL Server database, use the SqlRoleProvider.&lt;br /&gt;If your application uses Windows groups as roles, use the WindowsTokenRoleProvider. Note that this is recommended to be used with Windows Authentication only.&lt;br /&gt;If your application roles are in a store other than those previously listed, create a custom roles provider inheriting RoleProvider base class.&lt;br /&gt;Set the defaultProvider attribute on the &lt;rolemanager&gt;element to the chosen role provider.&lt;br /&gt;To check roles and manage roles, use the Role Manager API (for example Roles.IsUserInRole and Roles.CreateRole). For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000013.asp"&gt;How To: Use Role Manager in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authorhowtousewindowsgroupsforroleauthorization"&gt;&lt;/a&gt;How to use Windows groups for role authorization&lt;br /&gt;If you use Windows authentication, you can use the ASP.NET 2.0 Role Manager feature with the WindowsTokenRoleProvider for role-based authorization. In this scenario, Windows groups are used as roles.&lt;br /&gt;Enable role manager by setting the enabled attribute on the &lt;rolemanager&gt;element to true. Note that the Machine.config file contains a default configuration for a WindowsTokenRoleProvider instance named AspNetWindowsTokenRoleProvider. You can use this provider instance and set it as the default provider by modifying your Web.config file as follows. &lt;system.web&gt;&lt;br /&gt;&lt;rolemanager defaultprovider="AspNetWindowsTokenRoleProvider" enabled="true"&gt;&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;br /&gt;To check role membership to authorize callers, use the Role Manager APIs such as IsUserInRole. if(Roles.IsUserInRole("Readers")){};&lt;br /&gt;&lt;br /&gt;As in ASP.NET version 1.1, you can also directly check role membership by using the authenticated user's Windows token. You can do this by using manual, imperative, and declarative role checks. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_authorhowtoperformrolebasedauthorizationincode" target="_self"&gt;How to perform role-based authorization in code&lt;/a&gt; in this topic.&lt;br /&gt;&lt;a name="pagpractices0001_authorhowtouseauthorizationmanagerinaspnet"&gt;&lt;/a&gt;How to use Authorization Manager in ASP.NET&lt;br /&gt;The Role Manager feature provides an AuthorizationStoreRoleProvider that uses the Windows Server 2003 Authorization Manager.&lt;br /&gt;To use AuthorizationStoreRoleProvider:&lt;br /&gt;Create an Authorization Manager policy store in either Active Directory or ADAM and grant administrative or reader rights to your ASP.NET process account, such as the Network Service account.&lt;br /&gt;Enable role manager by setting the enabled attribute on the &lt;rolemanager&gt;element to true.&lt;br /&gt;Configure a connection string containing an LDAP query to point to your Authorization Manager (AzMan) policy store.&lt;br /&gt;Configure the AuthorizationStoreRoleProvider in Web.config.&lt;br /&gt;Set the defaultProvider attribute to your provider instance.&lt;br /&gt;A typical configuration is shown here. &lt;connectionstrings&gt;&lt;br /&gt;&lt;add name="AuthorizationServices" connectionstring="msldap://myserver:389/CN=Store,OU=SecNetPartition,O=SecNet,C=US"&gt;&lt;br /&gt;&lt;/connectionstrings&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;...&lt;br /&gt;&lt;rolemanager defaultprovider="AuthorizationStoreRoleProvider" enabled="true"&gt;&lt;br /&gt;&lt;providers&gt;&lt;br /&gt;&lt;add name="AuthorizationStoreRoleProvider" type="System.Web.Security.AuthorizationStoreRoleProvider" connectionstringname="AuthorizationServices" applicationname="SampleApplication"&gt;&lt;br /&gt;&lt;/providers&gt;&lt;br /&gt;&lt;/rolemanager&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;br /&gt;If you use an Authorization Manager policy store in Active Directory, the Authorization Manager policy roles are different from the Windows groups you define in Active Directory.&lt;br /&gt;Note that the AuthorizationStoreRoleProvider only exposes a subset of Authorization Manager's functionality. For example, you cannot use Authorization Manager's authorization business logic, such as tasks and operations. If you need to use tasks and operations you need to use COM interop and directly call members of the azroles 1.0 type library. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000019.asp"&gt;How To: Use Authorization Manager (AzMan) with ASP.NET 2.0&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000018.asp"&gt;How To: Use ADAM for Roles in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_authorhowtocacherolesinaspnet"&gt;&lt;/a&gt;How to cache roles in ASP.NET&lt;br /&gt;If a user's browser accepts cookies, you can cache role information for that user in a cookie on the user's computer. On each page request, ASP.NET reads the role information for that user from the cookie. This can improve application performance by reducing the amount of communication required with the data source to retrieve role information. If the role information for a user is too long to store in a cookie, ASP.NET stores only the most recently used role information in the cookie and then looks up additional role information in the data source as and when required.&lt;br /&gt;To configure and enable role caching, set cacheRoleInCookie to true on the &lt;rolemanager&gt;element as shown here. &lt;rolemanager defaultprovider="AspNetSqlRoleProvider" enabled="true" cacherolesincookie="true" cookiename=".ASPXROLES" cookietimeout="30" cookiepath="/" cookierequiressl="false" cookieslidingexpiration="true" cookieprotection="All" createpersistentcookie="false" maxcachedresults="25"&gt;&lt;br /&gt;&lt;br /&gt;To secure the cookie, set the cookieProtection attribute to All, to ensure that the cookie is signed and encrypted. Set cookieRequireSSL to true to ensure that the cookie is only transmitted over HTTPS connections. Set createPersistentCookie to false to ensure the cookie is not persisted on the client's computer, and then use the cookieTimeout attribute to set a limited cookie expiration time.&lt;br /&gt;&lt;a name="pagpractices0001_authorhowtoconfigureurlauthorizationinwebconfig"&gt;&lt;/a&gt;How to configure URL authorization in Web.config&lt;br /&gt;To configure URL authorization, use an &lt;authorization&gt;element in Web.config and specify which user and/or role names are allowed access to the current directory or the nominated directory or file. ASP.NET version 2.0 on Windows Server 2003 protects all files in a given directory, even those not mapped to ASP.NET, such as .html, .gif, and .jpg files.&lt;br /&gt;Authorization settings in Web.config refer to all of the files in the current directory and all subdirectories unless a subdirectory contains its own Web.config with an &lt;authorization&gt;element. In this case, the settings in the subdirectory override the parent directory settings.&lt;br /&gt;URL authorization can be used for both forms authentication and Windows authentication. In the case of Windows authentication, user names take the form "DomainName\WindowsUserName" and role names take the form "DomainName\WindowsGroupName". The local administrators group is referred to as "BUILTIN\Administrators". The local users group is referred to as "BUILTIN\Users". The following example shows Windows users and Windows roles. &lt;authorization&gt;&lt;br /&gt;&lt;allow users="DomainName\Bob, DomainName\Mary"&gt;&lt;br /&gt;&lt;allow roles="BUILTIN\Administrators, DomainName\Manager"&gt;&lt;br /&gt;&lt;deny users="*"&gt;&lt;br /&gt;&lt;/authorization&gt;&lt;br /&gt;&lt;br /&gt;The following example uses a custom role. &lt;authorization&gt;&lt;br /&gt;&lt;allow roles="Manager"&gt;&lt;br /&gt;&lt;deny users="*"&gt;&lt;br /&gt;&lt;/authorization&gt;&lt;br /&gt;&lt;br /&gt;To apply authorization rules to a specific file or folder, enclose the &lt;authorization&gt;element inside a &lt;location&gt;element as shown here. &lt;location path="Secure"&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;&lt;authorization&gt;&lt;br /&gt;&lt;deny users="?"&gt;&lt;br /&gt;&lt;/authorization&gt;&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;/location&gt;&lt;br /&gt;&lt;br /&gt;This example denies access to unauthenticated users and forces a redirect to the login page that is specified on the &lt;forms&gt;element.&lt;br /&gt;The following example shows how you can apply authorization to a specific file (Page.aspx). &lt;location path="page.aspx"&gt;&lt;br /&gt;&lt;authorization&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/authorization&gt;&lt;br /&gt;&lt;/location&gt;&lt;br /&gt;&lt;br /&gt;If necessary, you can apply different authorization rules for separate pages based on the identity, or more commonly, the role membership of the caller, by using multiple &lt;authorization&gt;elements within separate &lt;location&gt;elements.&lt;br /&gt;&lt;a name="pagpractices0001_authorhowtolockauthorizationsettings"&gt;&lt;/a&gt;How to lock authorization settings&lt;br /&gt;Server administrators can lock authorization settings by using the &lt;authorization&gt;element in the machine-level Web.config file. This ensures that an individual application cannot override machine-level policy. To lock authorization settings, surround the &lt;authorization&gt;element inside a &lt;location&gt;element and set allowOverride="false" as shown here. &lt;location path="" allowoverride="false"&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;&lt;authorization&gt;&lt;br /&gt;&lt;deny users="?"&gt;&lt;br /&gt;&lt;allow users="*"&gt;&lt;br /&gt;&lt;/authorization&gt;&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;/location&gt;&lt;br /&gt;&lt;br /&gt;This example forces authenticated access.&lt;br /&gt;&lt;a name="pagpractices0001_codeaccesssecurity"&gt;&lt;/a&gt;Code Access Security&lt;br /&gt;&lt;a name="pagpractices0001_codehowtousecodeaccesssecurityinaspnet"&gt;&lt;/a&gt;How to use code access security in ASP.NET&lt;br /&gt;Administrators can use code access security trust levels with ASP.NET to isolate applications and to restrict which resource types they can access and which privileged operations they can perform. The ability to isolate applications is particularly important in hosted environments, where multiple applications share the same server.&lt;br /&gt;To use code access security in ASP.NET, you need to evaluate requirements, choose a trust level, and configure the application to use the appropriate trust level.&lt;br /&gt;To use code access security in ASP.NET:&lt;br /&gt;Evaluate the required permissions. You can do this by either doing a manual code review or by using the PermCalc tool to help calculate the required permissions.&lt;br /&gt;Choose a standard trust level (High, Medium, Low, or Minimal) that meets application requirements. Ensure that you do not grant more permissions than needed. If you do not find a perfect match with standard trust levels, create a custom trust policy to meet application requirements.&lt;br /&gt;If your application needs medium trust, configure the application to use the trust level as shown here. &lt;system.web&gt;&lt;br /&gt;...&lt;br /&gt;&lt;trust originurl="" level="Medium"&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;...&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000017.asp"&gt;How To: Use Code Access Security in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_codehowtousecustomtrustlevelswithcodeaccesssecurityinaspnet"&gt;&lt;/a&gt;How to use custom trust levels with code access security in ASP.NET&lt;br /&gt;To use a custom trust level, create a custom trust file based on the existing trust file that most closely matches your application requirements.&lt;br /&gt;To create a custom level and configure an application to use it:&lt;br /&gt;Identify the trust level that satisfies most of your application's permission requirements.&lt;br /&gt;Copy the trust policy file for that level to create a custom trust policy file, for example web_CustomTrust.config.&lt;br /&gt;Add the additional permissions required. For example, to add the registry permission to a custom trust policy file:&lt;br /&gt;Add a &lt;securityclass&gt;element. &lt;securityclass name="RegistryPermission" description="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt;&lt;br /&gt;&lt;br /&gt;Add an &lt;ipermission&gt;element to the "ASP.Net" named permission set. &lt;permissionset class="NamedPermissionSet" name="ASP.Net" version="1"&gt;&lt;br /&gt;...&lt;br /&gt;&lt;ipermission class="RegistryPermission" version="1" unrestricted="true"&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/permissionset&gt;&lt;br /&gt;&lt;br /&gt;Configure your application's root Web.config file to make your application use the custom trust policy file. ...&lt;br /&gt;&lt;location allowoverride="false"&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;&lt;securitypolicy&gt;&lt;br /&gt;&lt;trustlevel name="Custom" policyfile="web_CustomTrust.config"&gt;&lt;br /&gt;&lt;/securitypolicy&gt;&lt;br /&gt;&lt;trust originurl="" level="Custom"&gt;&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;/location&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="pagpractices0001_codehowtoruninmediumtrust"&gt;&lt;/a&gt;How to run in Medium trust&lt;br /&gt;Medium trust ASP.NET 2.0 applications can now access SQL Server databases. Running at Medium trust is particularly useful for environments where multiple applications run on the same server and you need to ensure that applications are isolated from one another and from shared system resources.&lt;br /&gt;By running in Medium trust, applications have no access to unmanaged code, and file access is restricted to the application's own virtual directory hierarchy. Applications also have no access the registry, the event log, or OLE DB data sources. Your code is unable to use reflection, and it can only communicate with specific servers identified by the originUrl attribute on the &lt;trust&gt;element.&lt;br /&gt;To configure applications to run with Medium trust, set the level attribute of the &lt;trust&gt;element in the machine-level Web.config as shown here. &lt;location allowoverride="false"&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;...&lt;br /&gt;&lt;trust originurl="" level="Medium"&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;/location&gt;&lt;br /&gt;&lt;br /&gt;By setting allowOverride="false" on the &lt;location&gt;element, you prevent an individual application's Web.config file from overriding the machine-wide policy. Use the originUrl attribute to determine which HTTP servers applications can communicate with.&lt;br /&gt;If you need additional permissions beyond those granted by Medium trust policy, create a custom policy file and add the necessary permissions as described in &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_codehowtousecustomtrustlevelswithcodeaccesssecurityinaspnet" target="_self"&gt;How to use custom trust levels with code access security in ASP.NET&lt;/a&gt;. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000020.asp"&gt;How To: Use Medium Trust in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_configuration"&gt;&lt;/a&gt;Configuration&lt;br /&gt;&lt;a name="pagpractices0001_conhowtoencryptsensitivedatainmachineconfigandwebconfig"&gt;&lt;/a&gt;How to encrypt sensitive data in Machine.config and Web.config&lt;br /&gt;In ASP.NET 2.0, use the Aspnet_regiis.exe tool with the -pe (provider encryption) option to encrypt sections of the Machine.config and Web.config files.&lt;br /&gt;To encrypt the connectionStrings section by using the DPAPI provider with the machine key store (the default configuration), run the following command from a command prompt:&lt;br /&gt;aspnet_regiis -pe "connectionStrings" -app "/MachineDPAPI"&lt;br /&gt;-prov "DataProtectionConfigurationProvider"&lt;br /&gt;-pe specifies the configuration section to encrypt.&lt;br /&gt;-app specifies your Web application's virtual path. If your application is nested, you need to specify the nested path from the root directory, for example "/test/aspnet/MachineDPAPI"&lt;br /&gt;-prov specifies the provider name.&lt;br /&gt;The .NET Framework 2.0 SDK supports RSAProtectedConfigurationProvider and DPAPIProtectedConfigurationProvider protected configuration providers, which you use with the Aspnet_regiis.exe tool:&lt;br /&gt;RSAProtectedConfigurationProvider. This is the default provider and uses the RSA public key encryption to encrypt and decrypt data. Use this provider to encrypt configuration files for use on multiple Web servers in a Web farm.&lt;br /&gt;DPAPIProtectedConfigurationProvider. This provider uses the Windows Data Protection API (DPAPI) to encrypt and decrypt data. Use this provider to encrypt configuration files for use on a single Windows Server.&lt;br /&gt;The following sections often contain sensitive information that you need to encrypt:&lt;br /&gt;&lt;appsettings&gt;. Custom application settings.&lt;br /&gt;&lt;connectionstrings&gt;. Connection strings.&lt;br /&gt;&lt;identity&gt;. Web application identity. Can contain impersonation credentials.&lt;br /&gt;&lt;sessionstate&gt;. Contains connection string for out of process session provider.&lt;br /&gt;You do not need any special steps for decryption, because the ASP.NET runtime takes care of this for you. You cannot use the Aspnet_regiis.exe tool and protected configuration to encrypt the following sections in Web.config and Machine.config:&lt;br /&gt;&lt;processmodel&gt;, &lt;runtime&gt;, &lt;mscorlib&gt;, &lt;startup&gt;, &lt;system.runtime.remoting&gt;, &lt;configprotecteddata&gt;, &lt;satelliteassemblies&gt;, &lt;cryptographysettings&gt;, &lt;cryptonamemapping&gt;, and &lt;cryptoclasses&gt;.&lt;br /&gt;For these sections, use the Aspnet_setreg.exe tool. You must also use this tool with ASP.NET 1.1. For more information about AspNet-setreg.exe, see Microsoft Knowledge Base article 329290, &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/msdn.microsoft.com/default.aspx?scid=kb;en-us;329290"&gt;How to use the ASP.NET utility to encrypt credentials and session state connection strings&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_conhowtochoosebetweenmachineanduserkeystorage"&gt;&lt;/a&gt;How to choose between machine and user key storage&lt;br /&gt;The DPAPI and RSA protected configuration providers used to encrypt sensitive data in configuration files can use either machine stores or user stores for key storage. You can either store the key in the machine store and create an ACL for your specific application identity or store the key in a user store. In the latter case, you need to load the user account's profile to access the key.&lt;br /&gt;Use machine-level key storage when:&lt;br /&gt;Your application runs on its own dedicated server with no other applications.&lt;br /&gt;You have multiple applications on the same server that run using the same identity and you want those applications to be able to share sensitive information and the same encryption key.&lt;br /&gt;The DPAPI machine key is stored at the following location:&lt;br /&gt;%windir%\system32\Microsoft\Protect\S-1-5-18&lt;br /&gt;The RSA machine key is stored at the following location:&lt;br /&gt;\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys&lt;br /&gt;Use user-level key storage if:&lt;br /&gt;You run your application in a shared hosting environment and you want to ensure that your application's sensitive data is not accessible to other applications on the server. In this scenario, each application should have a separate identity so that they all have their own individual and private key stores.&lt;br /&gt;RSA user-level key containers are stored in the following folder:&lt;br /&gt;\Documents and Settings\{UserName}\Application Data\Microsoft\Crypto\RSA&lt;br /&gt;The DPAPI user key is stored in a folder at the following location:&lt;br /&gt;\Documents and Settings\{UserName}\Application Data\Microsoft\Protect&lt;br /&gt;&lt;a name="pagpractices0001_conhowtousedpapiwithauserstoretoencryptaconnectionstringinwebconfig"&gt;&lt;/a&gt;How to use DPAPI with a user store to encrypt a connection string in Web.config&lt;br /&gt;By default, the DataProtectionConfigurationProvider is configured to use DPAPI with the machine store. To use it with the user store, add a &lt;configprotecteddata&gt;section to your Web.config file and set the useMachineProtection attribute to false as shown here. You must also specify a unique provider name. &lt;configprotecteddata&gt;&lt;br /&gt;&lt;providers&gt;&lt;br /&gt;&lt;add name="MyUserDataProtectionConfigurationProvider" type="System.Configuration.DpapiProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" usemachineprotection="false" keyentropy=""&gt;&lt;br /&gt;&lt;/providers&gt;&lt;br /&gt;&lt;/configprotecteddata&gt;&lt;br /&gt;&lt;br /&gt;Then run the following command from a command prompt to encrypt the &lt;connectionstrings&gt;section:&lt;br /&gt;aspnet_regiis–pe "connectionStrings"–app "/UserDPAPI" -prov "MyUserDataProtectionConfigurationProvider"&lt;br /&gt;The &lt;providers&gt;configuration ensures that DPAPI is used with the user store. Make sure that your application is running with the same user identity as the account you used to encrypt the data. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000005.asp"&gt;How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_conhowtousersawithauserlevelkeycontainertoencryptaconnectionstringinwebconfig"&gt;&lt;/a&gt;How to use RSA with a user-level key container to encrypt a connection string in Web.config&lt;br /&gt;The RSAProtectedConfigurationProvider is the default provider and is configured to use the machine-level key container. To use it with a user-level key container, add a &lt;configprotecteddata&gt;section to your Web.config file and set the useMachineContainer attribute to false as shown here. &lt;configprotecteddata&gt;&lt;br /&gt;&lt;providers&gt;&lt;br /&gt;&lt;add name="MyUserRSAProtectedConfigurationprovider" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" description="Uses RsaCryptoServiceProvider to encrypt and decrypt" keycontainername="NetFrameworkConfigurationKey" usemachinecontainer="false"&gt;&lt;br /&gt;&lt;/providers&gt;&lt;br /&gt;&lt;/configprotecteddata&gt;&lt;br /&gt;&lt;br /&gt;Then run the following command from a command prompt to encrypt the &lt;connectionstrings&gt;section:&lt;br /&gt;aspnet_regiis -pe "connectionStrings" -app "/UserRSA"–prov "MyUserRSAProtectedConfigurationProvider"&lt;br /&gt;The &lt;providers&gt;configuration ensures that RSA is used with the user-level key container. Make sure that your application is running with the same user identity as the account you used to encrypt the data. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000006.asp"&gt;How To: Encrypt Configuration Sections in ASP.NET 2.0 Using RSA&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_conhowtorunanaspnetapplicationwithaparticularidentity"&gt;&lt;/a&gt;How to run an ASP.NET application with a particular identity&lt;br /&gt;In IIS 6.0, use IIS Manager to create an application pool running as a specific identity. Use IIS Manager to assign your application to that application pool.&lt;br /&gt;In IIS 5.0, you can configure the ASP.NET process identity by setting the userName and password attributes on the &lt;processmodel&gt;element in Machine.config. If you do this, you should encrypt the credentials by using the Aspnet_setreg.exe utility.&lt;br /&gt;&lt;a name="pagpractices0001_conhowtocreateaserviceaccountforaspnet"&gt;&lt;/a&gt;How to create a service account for ASP.NET&lt;br /&gt;To create a service account:&lt;br /&gt;Create a Windows account&lt;br /&gt;Run the following Aspnet_regiis.exe command to assign the relevant ASP.NET permissions to the account:&lt;br /&gt;aspnet_regiis.exe -ga machineName\userName&lt;br /&gt;On Windows 2003, running the Aspnet_regiis.exe -ga command will add the account to the IIS_WPG group. The IIS_WPG group provides the Log on as a batch job permission and ensures that the necessary file system permissions are granted.&lt;br /&gt;Note At the time of this writing, the Aspnet_regiis–ga command on .NET Framework 2.0 beta 2 does not add the account to the IIS_WPG group and this must be done manually. The release version of the .NET Framework 2.0 will fix this issue and the account will be added to the IIS_WPG group.&lt;br /&gt;Use the Local Security Policy tool to grant the Windows account the Deny logon locally user right. This reduces the privileges of the account and prevents anyone logging onto Windows locally with the account.&lt;br /&gt;Use IIS Manager to create an application pool running under the new account's identity and assign the ASP.NET application to the pool.&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000009.asp"&gt;How To: Create a Service Account for an ASP.NET 2.0 Application&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_conhowtoconfigurethemachinekeyinwebfarms"&gt;&lt;/a&gt;How to configure the machine key in Web farms&lt;br /&gt;You use the &lt;machinekey&gt;to specify keys and algorithms used by ASP.NET to protect Forms authentication tickets and ViewState. If you deploy your application in a Web farm, you must manually generate key values and ensure that the configuration files on each server share hashing and encryption keys.&lt;br /&gt;To generate cryptographically random keys:&lt;br /&gt;Use the RNGCryptoServiceProvider class to generate a cryptographically strong random number.&lt;br /&gt;Choose an appropriate key size. The recommended key lengths are as follows:&lt;br /&gt;For SHA1, set the validationKey to 64 bytes (128 hexadecimal characters).&lt;br /&gt;For AES, set the decryptionKey to 32 bytes (64 hexadecimal characters).&lt;br /&gt;For 3DES, set the decryptionKey to 24 bytes (48 hexadecimal characters).&lt;br /&gt;The following code shows how to generate random key values. Compile the code to create a console application, and then pass the required key size as a command line argument expressed as the desired number of hexadecimal characters. Each byte is represented by two hexadecimal characters; therefore, to request a 32-byte key, pass 64 as a command line argument. If you do not specify an argument, the code returns a 128 hexadecimal character (64-byte) key. // C# Example&lt;br /&gt;using System;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Security;&lt;br /&gt;using System.Security.Cryptography;&lt;br /&gt;class App {&lt;br /&gt;static void Main(string[] argv) {&lt;br /&gt;int len = 128;&lt;br /&gt;if (argv.Length &gt; 0)&lt;br /&gt;len = int.Parse(argv[0]);&lt;br /&gt;byte[] buff = new byte[len/2];&lt;br /&gt;RNGCryptoServiceProvider rng = new&lt;br /&gt;RNGCryptoServiceProvider();&lt;br /&gt;rng.GetBytes(buff);&lt;br /&gt;StringBuilder sb = new StringBuilder(len);&lt;br /&gt;for (int i=0; i&lt;buff.length; href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000007.asp"&gt;How To: Configure the Machine Key in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_conhowtolockconfigurationsettings"&gt;&lt;/a&gt;How to lock configuration settings&lt;br /&gt;To lock the configuration settings for all the Web applications on a Web server to prevent an individual application from overriding them, place the configuration settings inside a &lt;system.web&gt;element nested within a &lt;location&gt;element in the machine-level Web.config file, and then set the allowOverride attribute to false.&lt;br /&gt;The following example enforces the use of Windows authentication for all Web applications on the server. &lt;location allowoverride="false"&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;&lt;authentication mode="Windows"&gt;&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;/location&gt;&lt;br /&gt;&lt;br /&gt;If you need to apply and lock settings for a specific Web application, use the path attribute on the &lt;location&gt;element to identify the Web application as shown here. &lt;location path="Default Web Site/VDirName"&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;&lt;authentication mode="Windows"&gt;&lt;br /&gt;&lt;identity impersonate="false"&gt;&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;/location&gt;&lt;br /&gt;&lt;br /&gt;If you specify the path, it must be fully qualified and include the Web site name and virtual directory name.&lt;br /&gt;&lt;a name="pagpractices0001_dataaccess"&gt;&lt;/a&gt;Data Access&lt;br /&gt;&lt;a name="pagpractices0001_datahowtoprotectdatabaseconnectionstrings"&gt;&lt;/a&gt;How to protect database connection strings&lt;br /&gt;Place connection strings inside the &lt;connectionstrings&gt;setting in Web.config, and then encrypt the &lt;connectionstrings&gt;configuration section by using one of the protected configuration providers (RSA or DPAPI). For more information about doing this and choosing between RSA and DPAPI, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtoencryptsensitivedatainmachineconfigandwebconfig" target="_self"&gt;How to encrypt sensitive data in Machine.config and Web.config&lt;/a&gt; in the Configuration topic.&lt;br /&gt;&lt;a name="pagpractices0001_datahowtoaccessadatabasefromaspnet"&gt;&lt;/a&gt;How to access a database from ASP.NET&lt;br /&gt;Use Windows authentication where possible and use a least privileged service identity while connecting to SQL Server. Usually, this will be your least privileged application's process account. By using a service account, you benefit from connection pooling. If you need per user authorization in the database, you can use impersonation (and delegation) and access the database with the original caller's account, but this will prevent efficient connection pooling.&lt;br /&gt;&lt;a name="pagpractices0001_datahowtousewindowsauthenticationtoconnecttosqlserver"&gt;&lt;/a&gt;How to use Windows authentication to connect to SQL Server&lt;br /&gt;To use Windows authentication, configure SQL Server appropriately and then use a connection string that contains either "Trusted_Connection=Yes", or "Integrated Security=SSPI" as shown in the following code. The two strings are equivalent and both result in Windows authentication. "server=MySQL; Integrated Security=SSPI; database=Northwind"&lt;br /&gt;"server=MySQL; Trusted_Connection=Yes; database=Northwind"&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000008.asp"&gt;How To: Connect to SQL Server Using Windows Authentication in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_datahowtoaccesssqlserverbyusingsqlauthentication"&gt;&lt;/a&gt;How to access SQL Server by using SQL authentication&lt;br /&gt;If you cannot use Windows authentication to SQL Server, you must use SQL authentication.&lt;br /&gt;To use SQL authentication:&lt;br /&gt;Use a least-privileged user ID to connect to SQL.&lt;br /&gt;Use a strong password for the SQL user account.&lt;br /&gt;Secure the channel between the Web server and database server because credentials are passed in an unencrypted format. For example, use SSL or IPSec.&lt;br /&gt;Secure the SQL connection string (which contains plaintext credentials). For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtoencryptsensitivedatainmachineconfigandwebconfig" target="_self"&gt;How to encrypt sensitive data in Machine.config and Web.config&lt;/a&gt; in the Configuration topic.&lt;br /&gt;If you connect to a SQL Server database using credentials (user name and password), your connection string looks like the following. SqlConnectionString = "Server=YourServer\Instance;&lt;br /&gt;Database=YourDatabase;uid=YourUserName;&lt;br /&gt;pwd=YourStrongPassword;"&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000010.asp"&gt;How To: Connect to SQL Server Using SQL Authentication in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_datahowtousethenetworkserviceaccounttoconnecttosqlserver"&gt;&lt;/a&gt;How to use the Network Service account to connect to SQL Server&lt;br /&gt;The Network Service account has network credentials, so it can be used to access resources such as a database server in the same domain or in a domain with an appropriate trust relationship.&lt;br /&gt;Note If you grant access to the Network Service account, any application on the same Web server that runs using that identity has access. For individual authorization and application isolation, use distinct identities. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtocreateaserviceaccountforaspnet" target="_self"&gt;How to create a service account for ASP.NET&lt;/a&gt; in the Configuration topic.&lt;br /&gt;To grant access to SQL Server for the network service account:&lt;br /&gt;Create a SQL login for the Network Service account. The name appears as domainName\&lt;webservermachinename&gt;$ if your database is on a separate server. You can use Enterprise Manager or run the following SQL statement to create the SQL Login:&lt;br /&gt;exec sp_grantlogin [domainName\&lt;webservermachinename&gt;$]&lt;br /&gt;Create a database user in the required database and map the login to the database user. Or you can run the following SQL statement:&lt;br /&gt;exec sp_grantdbaccess [domainName\&lt;webservermachinename&gt;$]&lt;br /&gt;Place the database user in a database role. This enables you to assign permissions to roles instead of individual users, which helps should the user account change.&lt;br /&gt;Grant permissions to the role. Ideally, just grant execute permissions to selected stored procedures and provide no direct table access.&lt;br /&gt;Within the client application, use a connection string that contains either "Trusted_Connection=Yes" or "Integrated Security=SSPI". The two strings are equivalent and both result in Windows authentication (assuming that your SQL Server is configured for Windows authentication). For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000015.asp"&gt;How To: Use the Network Service Account to Access Resources in ASP.NET&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_datahowtopreventsqlinjection"&gt;&lt;/a&gt;How to prevent SQL injection&lt;br /&gt;Validate input and use parameterized stored procedures for data access. The use of parameters (for example, SqlParameterCollection) ensures that input values are checked for type and length and values outside the range throws an exception. Parameters are also treated as safe literal values and not executable code within the database. The following code shows how to use SqlParameterCollection when calling a stored procedure called LoginStoredProcedure which accepts @au_id of type varchar(11) as a parameter. using System.Data;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;using (SqlConnection connection = new SqlConnection(connectionString))&lt;br /&gt;{&lt;br /&gt;DataSet userDataset = new DataSet();&lt;br /&gt;SqlDataAdapter myCommand = new SqlDataAdapter(&lt;br /&gt;"LoginStoredProcedure", connection);&lt;br /&gt;myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;&lt;br /&gt;myCommand.SelectCommand.Parameters.Add("@au_id", SqlDbType.VarChar, 11);&lt;br /&gt;myCommand.SelectCommand.Parameters["@au_id"].Value = SSN.Text;&lt;br /&gt;myCommand.Fill(userDataset);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Avoid passing SQL queries to be executed as a parameter to a stored procedure. Instead pass query parameters only.&lt;br /&gt;Use structured exception handling to catch errors when accessing the database and prevent them from propagating back to the client. A detailed error message may reveal valuable information, such as the connection string, SQL server name, or table and database naming conventions that attackers can use for more precise attacks.&lt;br /&gt;As an additional precaution, use a least privileged account to access the database, so that even if your application is compromised the impact will be minimized. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000002.asp"&gt;How To: Protect From SQL Injection in ASP.NET&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_exceptionmanagement"&gt;&lt;/a&gt;Exception Management&lt;br /&gt;&lt;a name="pagpractices0001_exchowtohandleexceptionssecurely"&gt;&lt;/a&gt;How to handle exceptions securely&lt;br /&gt;Do not reveal internal system or application details, such as stack traces, SQL statement fragments, and table or database names. Ensure that this type of information is not allowed to propagate to the end user or beyond your current trust boundary. A malicious user could use system-level diagnostic information to learn about your application and probe for weaknesses to exploit in future attacks.&lt;br /&gt;If an exception is thrown, make sure your application fails securely, denies access, and is not left in an insecure state. Do not log sensitive or private data, such as passwords, that could be compromised. When you log or report exceptions, if user input is included in exception messages, validate it or sanitize it. For example, if you return an HTML error message, you should encode the output to avoid possible script injection.&lt;br /&gt;&lt;a name="pagpractices0001_exchowtopreventdetailederrorsfromreturningtotheclient"&gt;&lt;/a&gt;How to prevent detailed errors from returning to the client&lt;br /&gt;By default, in ASP.NET the mode attribute of the &lt;customerrors&gt;element is set to remoteOnly, which returns complete exception information (including the stack trace) only to callers on the same computer as the server. Remote callers receive filtered exception information. In a production environment, you should set the mode attribute to On, so that all callers receive filtered exception information. You should also specify a default redirect page as shown here. &lt;customerrors mode="On" defaultredirect="YourErrorPage.htm"&gt;&lt;br /&gt;&lt;br /&gt;The defaultRedirect attribute allows you to use a custom error page for your application, which, for example, might include support contact details. Do not use mode="Off" because this allows detailed error pages that contain system-level information to be returned to the client.&lt;br /&gt;Also set pageOutput="false" on the &lt;trace&gt;element to disable trace output. To prevent trace being accidentally being re-enabled, consider locking this for all applications on a server by applying the following configuration in the machine-level Web.config file. Enclose the &lt;trace&gt;element in a &lt;location&gt;element and set allowOverride to false. &lt;location path="" allowoverride="false"&gt;&lt;br /&gt;&lt;system.web&gt;&lt;br /&gt;&lt;trace pageoutput="false"&gt;&lt;br /&gt;&lt;/SYSTEM.WEB&gt;&lt;br /&gt;&lt;/location&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="pagpractices0001_exchowtousestructuredexceptionhandling"&gt;&lt;/a&gt;How to use structured exception handling&lt;br /&gt;Use try/catch/finally structured exception handling blocks around code to avoid unhandled exceptions. Use finally blocks to execute code that runs whether an exception is trapped; this is useful for releasing resources such as closing files or disposing of objects.&lt;br /&gt;&lt;a name="pagpractices0001_exchowtocreateaglobalerrorhandlerforyourapplication"&gt;&lt;/a&gt;How to create a global error handler for your application&lt;br /&gt;Define a global error handler in Global.asax to catch any exceptions that are not handled in code. You should log all exceptions in the event log to record them for tracking and later analysis. Use code similar to the following.&lt;br /&gt;&lt;br /&gt;&lt;script language="C#" runat="server"&gt;&lt;br /&gt;void Application_Error(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;//get reference to the source of the exception chain&lt;br /&gt;Exception ex = Server.GetLastError().GetBaseException();&lt;br /&gt;//log the details of the exception and page state to the&lt;br /&gt;//Event Log&lt;br /&gt;EventLog.WriteEntry("My Web Application",&lt;br /&gt;"MESSAGE: " + ex.Message +&lt;br /&gt;"\nSOURCE: " + ex.Source +&lt;br /&gt;"\nFORM: " + Request.Form.ToString() +&lt;br /&gt;"\nQUERYSTRING: " + Request.QueryString.ToString() +&lt;br /&gt;"\nTARGETSITE: " + ex.TargetSite +&lt;br /&gt;"\nSTACKTRACE: " + ex.StackTrace,&lt;br /&gt;EventLogEntryType.Error);&lt;br /&gt;//Optional email or other notification here...&lt;br /&gt;}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Note that you need to give your ASP.NET account the necessary permissions to write to the event log. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_audithowtowritetotheeventlog" target="_self"&gt;How to write to the event log&lt;/a&gt; in the Auditing and Logging topic.&lt;br /&gt;&lt;a name="pagpractices0001_exchowtospecifyadefaulterrorpage"&gt;&lt;/a&gt;How to specify a default error page&lt;br /&gt;Use the &lt;customerrors&gt;section of the Web.config file and set mode to On to specify a default error page to display, along with other required error pages for specific HTTP response codes that indicate errors. Use these custom error pages, as shown in the following example, to provide user friendly responses for errors not caught in a structured event handling block. &lt;customerrors mode="On" defaultredirect="ErrDefault.aspx"&gt;&lt;br /&gt;&lt;error redirect="ErrUnauthorized.aspx" statuscode="401"&gt;&lt;br /&gt;&lt;error redirect="ErrPageNotFound.aspx" statuscode="404"&gt;&lt;br /&gt;&lt;error redirect="ErrServer.htm" statuscode="500"&gt;&lt;br /&gt;&lt;/customerrors&gt;&lt;br /&gt;&lt;br /&gt;When debugging your application, the mode attribute of the &lt;customerrors&gt;element must be set to RemoteOnly (the default) to view the custom errors on remote clients and ASP.NET errors on the localhost.&lt;br /&gt;&lt;a name="pagpractices0001_impersonation"&gt;&lt;/a&gt;Impersonation and Delegation&lt;br /&gt;&lt;a name="pagpractices0001_imphowtochoosebetweentrustedsubsystemandimpersonationdelegation"&gt;&lt;/a&gt;How to choose between trusted subsystem and impersonation/delegation&lt;br /&gt;With the trusted subsystem model, you use your Web application's process identity to access downstream network resources such as databases. With impersonation/delegation, you use impersonation and use the original caller's identity to access the database.&lt;br /&gt;Trusted subsystem offers better scalability because your application benefits from efficient connection pooling. You also minimize back-end ACL management. Only the trusted identity can access the database. Your end users have no direct access. In the trusted subsystem model, the middle-tier service is granted broad access to back-end resources. As a result, a compromised middle-tier service could potentially make it easier for an attacker to gain broad access to back-end resources. Keeping the service account's credentials protected is essential.&lt;br /&gt;With impersonation/delegation, you benefit from operating system auditing because you can track which users have attempted to access specific resources. You can also enforce granular access controls in the database, and individual user accounts can be restricted independently of one another in the database.&lt;br /&gt;&lt;a name="pagpractices0001_imphowtoimpersonatetheoriginalcaller"&gt;&lt;/a&gt;How to impersonate the original caller&lt;br /&gt;ASP.NET does not impersonate the original caller by default. If you need to impersonate the original caller, set the mode attribute of the &lt;authentication&gt;element in the Web.config file to Windows and the impersonate attribute of the &lt;identity&gt;element to true.&lt;br /&gt;In IIS, disable anonymous access and select a Windows authentication mechanism. If you do not do this, the ASP.NET application will impersonate the anonymous IIS account IUSR_machineName.&lt;br /&gt;&lt;a name="pagpractices0001_imphowtotemporarilyimpersonatetheoriginalcaller"&gt;&lt;/a&gt;How to temporarily impersonate the original caller&lt;br /&gt;To temporarily impersonate the original caller in your application's Web.config file, set the mode attribute of the &lt;authentication&gt;element to Windows.&lt;br /&gt;In IIS, disable anonymous access and select a Windows authentication mechanism. In your code, use the Impersonate method of the System.Security.Principal.WindowsIdentity class, as shown here. using System.Security.Principal;&lt;br /&gt;...&lt;br /&gt;IIdentity WinId= HttpContext.Current.User.Identity;&lt;br /&gt;WindowsIdentity userId = (WindowsIdentity)WinId;&lt;br /&gt;// impersonate temporarily&lt;br /&gt;WindowsImpersonationContext wic = userId.Impersonate();&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;// run code, access resources using the original caller's&lt;br /&gt;// security context&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;// restore our old security context&lt;br /&gt;wic.Undo();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000023.asp"&gt;How To: Use Impersonation and Delegation in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_imphowtouseprotocoltransitionandconstraineddelegationinaspnet"&gt;&lt;/a&gt;How to use protocol transition and constrained delegation in ASP.NET&lt;br /&gt;Protocol transition allows an application on a designated server to use any method to authenticate the original caller and then to transition to the Kerberos protocol to access back-end network resources. This is particularly useful in scenarios where your users access your application over the Internet but firewalls prevent them from communicating directly with the domain controller. In this scenario, you can authenticate your users by using forms, client certificates, or some alternative authentication mechanism, and then create valid Windows tokens on the server for your users; use those and Kerberos authentication to access back-end network resources. You can then use constrained delegation to ensure that these tokens and their associated logon sessions can only be used to communicate with designated services on specific servers.&lt;br /&gt;To use protocol transition and constrained delegation, you must:&lt;br /&gt;Be on a specially designated server that is trusted for delegation.&lt;br /&gt;Use local security policy to grant the Act as part of the operating system privilege (TCB) to the account used to run ASP.NET on the Web tier (the Network Service account by default for IIS 6.0).&lt;br /&gt;Configure Active Directory for protocol transition and constrained delegation.&lt;br /&gt;On Windows Server 2003, the WindowsIdentity constructor uses the new Kerberos S4U extension to obtain a logon session and Windows token for a user without that user's password as shown here. using System.Security.Principal;&lt;br /&gt;...&lt;br /&gt;WindowsIdentity wi = new WindowsIdentity("username@domainName");&lt;br /&gt;WindowsImpersonationContext wic = wi.Impersonate();&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;// do work&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;// stop impersonating&lt;br /&gt;wic.Undo();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000024.asp"&gt;How To: Use Protocol Transition and Constrained Delegation in ASP.NET 2.0&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_inputanddatavalidation"&gt;&lt;/a&gt;Input and Data Validation&lt;br /&gt;&lt;a name="pagpractices0001_inputhowtovalidateinputinaspnet"&gt;&lt;/a&gt;How to validate input in ASP.NET&lt;br /&gt;Assume all input is malicious. To validate input, define acceptable input for your fields. Constrain input for length, range, format, and type. Use an "allow" approach up front and define what constitutes valid input instead of relying on "deny" approaches. The problem with a "deny" approach is that it is very difficult to anticipate all possible variations of bad input. Do not rely on client-side validation as your only input validation mechanism because it can be easily bypassed. Use client-side validation only to reduce round trips and to improve the user experience. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000003.asp"&gt;How To: Protect From Injection Attacks in ASP.NET&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_inputhowtovalidateinputinservercontrols"&gt;&lt;/a&gt;How to validate input in server controls&lt;br /&gt;Validate input from server controls by using the ASP.NET validation controls, such as the RangeValidator, RequiredFieldValidator, CustomValidator, or RegularExpressionValidator. The following example shows a RegularExpressionValidator control that has been used to validate a name field. &lt;form id="WebForm" method="post" runat="server"&gt;&lt;br /&gt;&lt;?xml:namespace prefix = asp /&gt;&lt;asp:textbox id="txtName" runat="server"&gt;&lt;/asp:textbox&gt;&lt;br /&gt;&lt;asp:regularexpressionvalidator id="nameRegex" runat="server" controltovalidate="txtName" validationexpression="^[a-zA-Z'.\s]{1,40}$" errormessage="Invalid name"&gt;&lt;br /&gt;&lt;/asp:regularexpressionvalidator&gt;&lt;br /&gt;&lt;/form&gt;&lt;br /&gt;&lt;br /&gt;The validation controls use client-side script to perform validation on the client browser (if supported by the browser), and also run validation logic on the server after data is posted back.&lt;br /&gt;&lt;a name="pagpractices0001_inputhowtovalidateinputinhtmlcontrolsquerystringcookiesandhttpheaders"&gt;&lt;/a&gt;How to validate input in HTML controls, QueryString, cookies, and HTTP headers&lt;br /&gt;Use the System.Text.RegularExpression.Regex class to validate this type of input to verify that the input matches an expected format, as shown in the following example. // Static method:&lt;br /&gt;if (!Regex.IsMatch(Request.QueryString.Get("Number"),&lt;br /&gt;@"\d{3}-\d{2}-\d{4}"))&lt;br /&gt;{&lt;br /&gt;// Invalid Social Security Number&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000001.asp"&gt;How To: Use Regular Expressions to Constrain Input in ASP.NET&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_inputhowtopreventcrosssitescripting"&gt;&lt;/a&gt;How to prevent cross site scripting&lt;br /&gt;Validate input and encode output. Constrain input by validating it for type, length, format, and range. Use the HttpUtility.HtmlEncode method to encode output if it contains input from the user, such as input from form fields, query strings, and cookies or from other sources, such as databases. Never just echo input back to the user without validating and/or encoding the data. The following example shows how to encode a form field. Response.Write(HttpUtility.HtmlEncode(Request.Form["name"]));&lt;br /&gt;&lt;br /&gt;If you return URL strings that contain input to the client, use the HttpUtility.UrlEncode method to encode these URL strings, as shown here. Response.Write(HttpUtility.UrlEncode(urlString));&lt;br /&gt;&lt;br /&gt;If you have pages that need to accept a range of HTML elements, such as through some kind of rich text input field, you must disable ASP.NET request validation for the page.&lt;br /&gt;To safely allow restricted HTML input:&lt;br /&gt;Disable ASP.NET request validation by the adding the ValidateRequest="false" attribute to the @ Page directive.&lt;br /&gt;Encode the string input with the HtmlEncode method.&lt;br /&gt;Use a StringBuilder and call its Replace method to selectively remove the encoding on the HTML elements that you want to permit as shown here. ...&lt;br /&gt;// Encode the string input from the HTML input text field&lt;br /&gt;StringBuilder sb = new StringBuilder(HttpUtility.HtmlEncode(htmlInputTxt.Text));&lt;br /&gt;// Selectively allow &lt;b&gt;and &lt;i&gt;&lt;br /&gt;sb.Replace("&amp;lt;b&amp;gt;", "&lt;b&gt;");&lt;br /&gt;sb.Replace("&amp;lt;/b&amp;gt;", "&lt;/b&gt;");&lt;br /&gt;sb.Replace("&amp;lt;i&amp;gt;", "&lt;i&gt;");&lt;br /&gt;sb.Replace("&amp;lt;/i&amp;gt;", "&lt;/i&gt;");&lt;br /&gt;&lt;br /&gt;For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/paght000004.asp"&gt;How To: Prevent Cross-Site Scripting in ASP.NET&lt;/a&gt;.&lt;br /&gt;&lt;a name="pagpractices0001_securecommunicatioin"&gt;&lt;/a&gt;Secure Communication&lt;br /&gt;&lt;a name="pagpractices0001_sechowtochoosebetweenipsecandssl"&gt;&lt;/a&gt;How to choose between IPSec and SSL&lt;br /&gt;Use Secure Sockets Layer (SSL) to protect the communication channel between specific client applications and a server. For example, you could use SSL to secure the channel between a specific Web application and a remote SQL Server. Use SSL when you need granular channel protection for a particular application instead of for all applications and services running on a computer.&lt;br /&gt;Use Internet Protocol Security (IPSec) to secure the communication channel between two servers and to restrict which computers can communicate with one another. For example, you can help secure a database server by establishing a policy that permits requests only from a trusted client computer, such as an application or Web server. You can also restrict communication to specific IP protocols and TCP/UDP ports.&lt;br /&gt;&lt;a name="pagpractices0001_sechowtosecurecommunicationbetweenbrowserclientsandwebserver"&gt;&lt;/a&gt;How to secure communication between browser clients and Web server&lt;br /&gt;Use SSL to create a secure encrypted communication channel between browser clients and Web server.&lt;br /&gt;To use SSL:&lt;br /&gt;Install a server certificate on the Web server.&lt;br /&gt;Install the root certificate authority (CA) certificate from the same authority into the local computer's Trusted Root Certification Authorities certificate store.&lt;br /&gt;Use IIS to configure the server to force the use of encryption while accessing Web pages.&lt;br /&gt;Design your pages with SSL in mind to minimize performance overhead. Optimize pages that use SSL by including less text and simple graphics and partition your site and ensure that only those pages than contain sensitive data use SSL.&lt;br /&gt;&lt;a name="pagpractices0001_sechowtosecurecommunicationbetweenservers"&gt;&lt;/a&gt;How to secure communication between servers&lt;br /&gt;Use IPSec to secure the communication channel between two servers and to place restrictions on which client computers can communicate with the server. For example, you can configure IPSec policy to only allow a specific application server to communicate with a database server. Also use IPSec to restrict which TCP port is used for communication and to encrypt all IP traffic that flows between the two servers.&lt;br /&gt;Note that if you restrict all communication, the database server will be unable to communicate with a domain controller. In this scenario, you must use mirrored local accounts (with the same user name and password) on both computers.&lt;br /&gt;&lt;a name="pagpractices0001_sensitivedata"&gt;&lt;/a&gt;Sensitive Data&lt;br /&gt;&lt;a name="pagpractices0001_senhowtoprotectsensitivedatainadatabase"&gt;&lt;/a&gt;How to protect sensitive data in a database&lt;br /&gt;If you need to protect data in a database that is accessed by multiple Web servers, you need to encrypt the data with a strong symmetric encryption algorithm and protect the encryption key with DPAPI.&lt;br /&gt;To encrypt sensitive data in a database accessed by multiple servers in a Web farm:&lt;br /&gt;Use a strong symmetric encryption algorithm such as 3DES or AES.&lt;br /&gt;Use the System.Security.Cryptography.RNGCryptoServiceProvider class to generate a strong (192 bit, 24 byte) encryption key. Back up the encryption key, and store the backup in a physically secure location.&lt;br /&gt;Note Cryptographically, 3 DES keys are effectively 168 bits in length rather than 192 bits. This is because in each of the three DES applications, a 56 bit key is used even though the block size is 64. The remainder of the 8 bits were meant to be parity bits but were never really used for that purpose. 3DES therefore, uses three times 56 or 168 bit keys.&lt;br /&gt;Use DPAPI to encrypt the symmetric encryption key on each Web server and store it in a secured registry key. Create an ACL to protect the registry key that allows full control for administrators and read only access for your ASP.NET process account.&lt;br /&gt;To encrypt data and decrypt data, retrieve the encrypted symmetric encryption key from the registry, use DPAPI to decrypt the key and then use the System.Security.Cryptography.TripleDESCryptoServiceProvider class with the encryption key to either encrypt or decrypt the data stored in the database.&lt;br /&gt;With this process, if the DPAPI account used to encrypt the encryption key is damaged, the backup of the 3DES key can be retrieved from the backup location and be encrypted using DPAPI under a new account. The new encrypted key can be stored in the registry and the data in the database can still be decrypted.&lt;br /&gt;&lt;a name="pagpractices0001_senhowtoencryptconfigurationdatainawebfarm"&gt;&lt;/a&gt;How to encrypt configuration data in a Web farm&lt;br /&gt;To encrypt configuration data in a Web farm, use RSA encryption with a machine-level key container because you can easily export RSA keys. You need to do this if you encrypt data in a Web.config file prior to deploying it to other servers in a Web farm. In this case, the private key required to decrypt the data must be exported and deployed to the other servers.&lt;br /&gt;In the following approach, you create and export a custom RSA encryption key. Then you install it on the target servers and secure it with an ACL that permits access only to your application's identity.&lt;br /&gt;To use RSA to encrypt data in a Web farm:&lt;br /&gt;Run the following command from a command prompt to create an exportable custom RSA encryption key:&lt;br /&gt;aspnet_regiis -pc "CustomKeys"–exp&lt;br /&gt;You can verify that a custom key container exists by looking for the file and checking timestamps in the following location:&lt;br /&gt;\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys&lt;br /&gt;Add and configure a custom protected configuration provider by adding a &lt;configprotecteddata&gt;section to your Web.config file. Note that the key container name is set to "CustomKeys" which is the name of the key container created previously. ...&lt;br /&gt;&lt;configprotecteddata&gt;&lt;br /&gt;&lt;providers&gt;&lt;br /&gt;&lt;add name="CustomProvider" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" description="Uses RsaCryptoServiceProvider to encrypt and decrypt" keycontainername="CustomKeys" usemachinecontainer="true"&gt;&lt;br /&gt;&lt;/providers&gt;&lt;br /&gt;&lt;/configprotecteddata&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;Run the following command from a command prompt to encrypt the connectionStrings section using the custom RSA key:&lt;br /&gt;aspnet_regiis -pe "connectionStrings" -app "/WebFarmRSA " -prov "CustomProvider"&lt;br /&gt;Run the following command from a command prompt to export the custom RSA encryption key:&lt;br /&gt;aspnet_regiis -px "CustomKeys" "C:\CustomKeys.xml" -pri&lt;br /&gt;The -pri switch causes the private and public key to be exported. This enables both encryption and decryption. Without the–pri switch, you would only be able to encrypt data with the exported key.&lt;br /&gt;Deploy the application and the encrypted Web.config file to a different server computer. Also copy the CustomKeys.xml file to a local directory on the other server, for example to the C:\ directory.&lt;br /&gt;On the destination server, run the following command from a command prompt to import the custom RSA encryption keys:&lt;br /&gt;aspnet_regiis -pi "CustomKeys" "C:\CustomKeys.xml"&lt;br /&gt;Grant access to the key container to your ASP.NET application identity. The following command grants access to the CustomKeys store to the Network Service account:&lt;br /&gt;aspnet_regiis -pa "CustomKeys" "NT Authority\Network Service"&lt;br /&gt;&lt;a name="pagpractices0001_senhowtoprotectviewstate"&gt;&lt;/a&gt;How to protect ViewState&lt;br /&gt;ViewState sent between browser and server is subject to tampering and eavesdropping threats. To detect tampering, ensure that ViewState is integrity checked with HMACs. This is the default setting.&lt;br /&gt;Avoid storing sensitive data in ViewState. If you must store sensitive data in ViewState, encrypt it. A common example is the DataKeyNames property of the GridView/DetailsView/FormView controls, which retains the values of the primary key fields of a data store in ViewState. Under some circumstances, these values could be sensitive, such as an employee ID. In this case, encrypt the ViewState.&lt;br /&gt;To encrypt ViewState:&lt;br /&gt;A control on a page needs can explicitly request ViewState encryption by calling the RegisterRequiresViewStateEncryption method.&lt;br /&gt;Alternatively, set the viewStateEncryptionMode attribute to Always.&lt;br /&gt;Alternatively, set the viewStateEncryptionMode attribute to Always in the the &lt;pages&gt;element of the Web.config file or you can use an equivalent viewStateEncryptionMode attribute on the @Page directive.&lt;br /&gt;If you use ViewState HMACs or encryption, and you deploy your application in a Web farm, you must ensure that the configuration files on each server share hashing and encryption keys. For more information, see &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnpag2/html/PAGPractices0001.asp#pagpractices0001_conhowtoconfigurethemachinekeyinwebfarms" target="_self"&gt;How to configure the machine key in Web farms&lt;/a&gt; in the Configuration topic.&lt;br /&gt;&lt;a name="pagpractices0001_senhowtoprotectpasswords"&gt;&lt;/a&gt;How to protect passwords&lt;br /&gt;You should store passwords in a non-reversible hashed format. Generate the hash from a combination of the password and a random salt value. Use an algorithm such as SHA256. The salt value helps to slow an attacker perform a dictionary attack should your credential store be compromised, giving you additional time to detect and react to the compromise.&lt;br /&gt;To store password hashes:&lt;br /&gt;Generate a random salt value by using the following code. byte[] salt = new byte[32];&lt;br /&gt;System.Security.Cryptography.RNGCryptoServiceProvider.Create().GetBytes(salt);&lt;br /&gt;&lt;br /&gt;Append the salt to the password. // Convert the plain string password into bytes&lt;br /&gt;byte[] plainTextBytes = System.Text UnicodeEncoding.Unicode.GetBytes(plainText);&lt;br /&gt;// Append salt to password before hashing&lt;br /&gt;byte[] combinedBytes = new byte[plainTextBytes.Length + salt.Length];&lt;br /&gt;System.Buffer.BlockCopy(plainTextBytes, 0, combinedBytes, 0, plainTextBytes.Length);&lt;br /&gt;System.Buffer.BlockCopy(salt, 0, combinedBytes, plainTextBytes.Length, salt.Length);&lt;br /&gt;&lt;br /&gt;Hash the combined password and salt by using the following code. // Create hash for the password+salt&lt;br /&gt;System.Security.Cryptography.HashAlgorithm hashAlgo = new System.Security.Cryptography.SHA256Managed();&lt;br /&gt;byte[] hash = hashAlgo.ComputeHash(combinedBytes);&lt;br /&gt;&lt;br /&gt;Append the salt to the resultant hash. // Append the salt to the hash&lt;br /&gt;byte[] hashPlusSalt = new byte[hash.Length + salt.Length];&lt;br /&gt;System.Buffer.BlockCopy(hash, 0, hashPlusSalt, 0, hash.Length);&lt;br /&gt;System.Buffer.BlockCopy(salt, 0, hashPlusSalt, hash.Length, salt.Length);&lt;br /&gt;&lt;br /&gt;Store the result in your user store database.&lt;br /&gt;This approach means you do not need to store the salt separately. To verify a password, you extract the salt from the stored combination of the hash and salt value and then recomputed the hash using the salt value and the plaintext password value obtained from the user.&lt;br /&gt;&lt;a name="pagpractices0001_companionguidance"&gt;&lt;/a&gt;Companion Guidance&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-113378096636610616?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/113378096636610616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=113378096636610616' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/113378096636610616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/113378096636610616'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/12/security-practices-aspnet-20-security_05.html' title='Security Practices: ASP.NET 2.0 Security Practices at a Glance'/><author><name>Ahsan</name><uri>http://www.blogger.com/profile/12740497037200673524</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-113004811191342553</id><published>2005-10-22T23:15:00.000-07:00</published><updated>2005-10-22T23:15:12.053-07:00</updated><title type='text'>XML (XMLType) inside PL/SQL Oracle 9/10</title><content type='html'>The &lt;strong&gt;XMLType&lt;/strong&gt; is an OO XML aware data type. It can be used in columns or in PL/SQL just like VARCHAR2 or DATE. XMLType has member functions that allow access to data using XPath.&lt;br /&gt;&lt;br /&gt;A quick example extracting a specific value from an XML varchar2 string:&lt;br /&gt;DECLARE&lt;br /&gt;  v VARCHAR2(32000) := '&lt;DATA&gt;&lt;LINE&gt;A&lt;/LINE&gt;&lt;LINE&gt;B&lt;/LINE&gt;&lt;LINE&gt;C&lt;/LINE&gt;&lt;/DATA&gt;';&lt;br /&gt;  x XMLType;&lt;br /&gt;BEGIN&lt;br /&gt;  x := XMLType(v);&lt;br /&gt;  DBMS_OUTPUT.put_line(&lt;br /&gt;     x.extract('/DATA/LINE[1]').getStringVal()&lt;br /&gt;     );&lt;br /&gt;  DBMS_OUTPUT.put_line(&lt;br /&gt;     x.extract('/DATA/LINE[1]/text()').getStringVal()&lt;br /&gt;     );&lt;br /&gt;END;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-113004811191342553?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/113004811191342553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=113004811191342553' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/113004811191342553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/113004811191342553'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/10/xml-xmltype-inside-plsql-oracle-910.html' title='XML (XMLType) inside PL/SQL Oracle 9/10'/><author><name>Habib Qureshi</name><uri>https://profiles.google.com/113730817373262408436</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-ZWt3OfX7_XY/AAAAAAAAAAI/AAAAAAAAAQA/onuiVxb4d8Q/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112782059808889090</id><published>2005-09-27T04:29:00.000-07:00</published><updated>2005-09-27T04:29:58.093-07:00</updated><title type='text'>WinFX Developer Center: InfoCard: The Laws of Identity</title><content type='html'>&lt;a href="http://msdn.microsoft.com/winfx/building/infocard/default.aspx?pull=/library/en-us/dnwebsrv/html/lawsofidentity.asp"&gt;WinFX Developer Center: InfoCard: The Laws of Identity&lt;/a&gt;: "The Laws of Identity"&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112782059808889090?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112782059808889090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112782059808889090' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112782059808889090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112782059808889090'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/09/winfx-developer-center-infocard-laws.html' title='WinFX Developer Center: InfoCard: The Laws of Identity'/><author><name>Hammad</name><uri>http://www.blogger.com/profile/15134916221126439154</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_ySWRHLE5dUA/RjMuR3xILFI/AAAAAAAAABo/vV87yWYuWfk/s320/dilbert.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112729446099939443</id><published>2005-09-21T02:21:00.000-07:00</published><updated>2005-09-21T02:21:01.010-07:00</updated><title type='text'>Fields to Properties (Visual Studio.Net)</title><content type='html'>Yes, we miss Automatic property generation from the Fields of the classes in the Visual Studio.net IDE.&lt;br /&gt;Following is the sample code of the Macro, I am telling here which I used for myself.&lt;br /&gt;This member variable to Property generation is not generic and is very difficult to be. The idea is that I demonstrate to do it my way and you can customize it for your needs.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Code is in the Visual Basic.Net&lt;/em&gt;&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;strong&gt;NEED:&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;&lt;br /&gt;Public Class AClass&lt;br /&gt;&lt;br /&gt;#Region "Members"&lt;br /&gt;	Private strStaffId As String&lt;br /&gt;	Private strStaffName As String&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;--&gt;&lt;br /&gt;Public Class AClass&lt;br /&gt;&lt;br /&gt;#Region "Members"&lt;br /&gt;	Private strStaffId As String&lt;br /&gt;	Public Property StaffId() As String&lt;br /&gt;		Get&lt;br /&gt;			Return strStaffId&lt;br /&gt;		End Get&lt;br /&gt;		Set(ByVal Value As String)&lt;br /&gt;			strStaffId = Value&lt;br /&gt;		End Set&lt;br /&gt;	End Property&lt;br /&gt;&lt;br /&gt;	Private strStaffName As String&lt;br /&gt;	Public Property StaffId() As String&lt;br /&gt;		Get&lt;br /&gt;			Return strStaffId&lt;br /&gt;		End Get&lt;br /&gt;		Set(ByVal Value As String)&lt;br /&gt;			strStaffId = Value&lt;br /&gt;		End Set&lt;br /&gt;	End Property&lt;br /&gt;&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;End Class&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;br /&gt;The first step in using a macro to generate code is to open the Macros IDE, add a new module, a macro, and stub out the code template. &lt;br /&gt;&lt;br /&gt;   1. To create a new macro, open Visual Studio .NET—I am using VS.NET 2003, but the example works in version 1—and select Tools|Macros|Macros IDE&lt;br /&gt;   2. In the Macros Project Explorer click on the MyMacros project, right-clicking Add|Add Module from the Project Explorer context menu&lt;br /&gt;   3. Add a public subroutine named WriteProperty to the module&lt;br /&gt;&lt;br /&gt;So, In my case it is like:&lt;br /&gt;&lt;strong&gt;File:- MyModule&lt;/strong&gt;&lt;br /&gt;Imports EnvDTE&lt;br /&gt;Imports System&lt;br /&gt;Imports System.Diagnostics&lt;br /&gt;&lt;br /&gt;Public Module MyModule&lt;br /&gt;&lt;br /&gt;    Private Cr As String = Environment.NewLine&lt;br /&gt;&lt;br /&gt;    Private mask As String = _&lt;br /&gt;    "Public Property {0}() As {1}" + Cr + _&lt;br /&gt;    "      Get" + Cr + _&lt;br /&gt;    "           Return {2}" + Cr + _&lt;br /&gt;    "      End Get" + Cr + _&lt;br /&gt;    "       Set(ByVal Value As {1})" + Cr + _&lt;br /&gt;    "           {2} = Value" + Cr + _&lt;br /&gt;    "       End Set" + Cr + _&lt;br /&gt;    "   End Property" + Cr&lt;br /&gt;&lt;br /&gt;    Public Sub WriteProperty()&lt;br /&gt;        Dim Selection As TextSelection = DTE.ActiveDocument.Selection&lt;br /&gt;&lt;br /&gt;        Dim FieldName As String&lt;br /&gt;        Dim PropertyName As String&lt;br /&gt;        Dim PropertyType As String&lt;br /&gt;&lt;br /&gt;        FieldName = Selection.Text&lt;br /&gt;        PropertyName = FieldName.Substring(3) 'skip strUserName -&gt; UserName&lt;br /&gt;&lt;br /&gt;        Selection.EndOfLine()&lt;br /&gt;        Selection.WordLeft(True)&lt;br /&gt;        PropertyType = Selection.Text&lt;br /&gt;        Selection.EndOfLine()&lt;br /&gt;        Selection.NewLine(2)&lt;br /&gt;&lt;br /&gt;        Dim vp As VirtualPoint = Selection.ActivePoint&lt;br /&gt;        Selection.Insert(String.Format(mask, PropertyName, PropertyType, FieldName))&lt;br /&gt;    End Sub&lt;br /&gt;End Module&lt;br /&gt;&lt;strong&gt;-----------------------------------------------------------------------&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Now, You can customize the VisualStudio environment and put a button on a toolbar and that button can call our macro. You can also assign a hot key to call this code.&lt;br /&gt;To generate the property for the field, You only have to select the field and it will generate its code for the corresponding property.&lt;br /&gt;&lt;br /&gt;When done, you only need to edit this code according to your needs.&lt;br /&gt;&lt;br /&gt;bye&lt;br /&gt;:)&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112729446099939443?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112729446099939443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112729446099939443' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112729446099939443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112729446099939443'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/09/fields-to-properties-visual-studionet.html' title='Fields to Properties (Visual Studio.Net)'/><author><name>Habib Qureshi</name><uri>https://profiles.google.com/113730817373262408436</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-ZWt3OfX7_XY/AAAAAAAAAAI/AAAAAAAAAQA/onuiVxb4d8Q/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112686389300800272</id><published>2005-09-16T02:43:00.000-07:00</published><updated>2005-09-16T02:44:53.016-07:00</updated><title type='text'>Windows WorkFlow Foundation</title><content type='html'>Windows Workflow Foundation is the programming model, engine and tools for quickly building workflow enabled applications on Windows. It consists of a WinFX namespace, an in-process workflow engine, and designers for Visual Studio 2005. Windows Workflow Foundation is available (currently in beta) for both client and server versions of Windows. Windows Workflow Foundation includes support for both system workflow and human workflow across a wide range of scenarios including: workflow within line of business applications, user interface page-flow, document-centric workflow, human workflow, composite workflow for service oriented applications, business rule driven workflow and workflow for systems management.&lt;br /&gt;The Windows Workflow Foundation namespace in WinFX is called System.Workflow. Windows Workflow Foundation provides a consistent and familiar development experience with other WinFX technologies such as ASP.NET, Windows Communication Foundation and Windows Presentation Foundation. Windows Workflow Foundation provides full support for Visual Basic .NET and C#, debugging, a graphical workflow designer and the ability to develop your workflow completely in code. Windows Workflow Foundation also provides an extensible model and designer to build custom activities which encapsulate workflow functionality for end-users or for re-use across multiple projects. Windows Workflow Foundation will be used across many future Microsoft products including The Microsoft Office System, BizTalk Server and the Microsoft Dynamics Products (previously known as Microsoft Business Solutions products). Most applications can benefit from the asynchronous state management features of the workflow model, the rapid development features of the designer, the potential for end-user flexibility, and the increased visibility into run-time code execution.&lt;br /&gt;A workflow is a set of activities stored as a model that describe a real world process. Work passes through the model from start to finish and activities might be executed by people or by system functions. Workflow provides a way of describing the order of execution and dependent relationships between pieces of short or long running work. While it is possible to write a workflow completely in code, workflow is often best viewed graphically. Once a workflow model is compiled it can be executed inside any Windows process including console apps, forms- based apps, Windows Services, ASP.NET web sites and web services.&lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://msdn.microsoft.com/windowsvista/building/workflow/default.aspx?pull=/library/en-us/dnlong/html/WWFIntro.asp"&gt;Introducing Windows Workflow Foundation&lt;/a&gt;Describes the functionality and benefits of Microsoft Windows Workflow Foundation, soon to be a standard part of the Microsoft Windows platform. Windows Workflow Foundation provides a general framework for defining workflow, one that can be used in many kinds of applications.   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://msdn.microsoft.com/windowsvista/building/workflow/default.aspx?pull=/library/en-us/dnlong/html/WWFGetStart.asp"&gt;Getting Started with Windows Workflow Foundation&lt;/a&gt;Learn about the technologies and features of Microsoft Windows Workflow Foundation that will be of interest to developers in need of creating workflow-driven applications for the Microsoft .NET platform.   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://www.microsoft.com/presspass/events/pdc/default.mspx"&gt;Press Release Announcing Windows Workflow Foundation &lt;/a&gt;Microsoft announced Windows Workflow Foundation on Sept. 14, 2005, as the programming model, engine and tools for quickly building workflow-enabled applications on Windows. Read the entire press release here.   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://msdn.microsoft.com/vstudio/tryit/hosted/windowsworkflow"&gt;Try out Windows Workflow Foundation online at MSDN VirtualLab&lt;/a&gt;The Visual Studio Hosted Experience lets you quickly evaluate developing with Windows Workflow Foundation with an online 1 hour hands on lab. You can work through this lab without installing anything on your local computer.   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://www.microsoft.com/downloads/details.aspx?familyid=7096d039-2638-4f63-8654-d2e5d98fa417&amp;displaylang=en"&gt;Download the Beta 1 of the Microsoft Visual Studio 2005 Extensions for Windows Workflow Foundation&lt;/a&gt;The Microsoft Visual Studio 2005 Extensions for Windows Workflow Foundation are the tools you need to develop workflow based applications now. Visual Studio 2005 Beta 1 is required for this download. The download page also has links to the full WinFX download which includes Windows Workflow Foundation.   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://blogs.msdn.com/pandrew/articles/460630.aspx"&gt;Join WebCasts on Windows Workflow Foundation&lt;/a&gt;Come join our planned (and past) webcasts for Windows Workflow Foundation. These start the week of the PDC with an introduction talk and continue shortly thereafter with the Week of Workflow WebCasts later in September 2005.   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=35238943-291F-4A37-BB8F-AC09B2E25B2F&amp;displaylang=en"&gt;Download a set of 12 Hands-On Labs to try on your machine&lt;/a&gt;At the Professional Developers Conference we had 12 labs for attendees to try Windows Workflow Foundation. These labs have been made available for you to download and use on your machine.   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://www.develop.com/courses/ewwf"&gt;Take a DevelopMentor Training Course&lt;/a&gt;Get an in-depth look at developing software using Microsoft's new workflow framework at DevelopMentor's "Essential Windows Workflow Foundation" course (4 days).   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?isbn=0672328488"&gt;Presenting Windows Workflow Foundation published by Sams Publishing &lt;/a&gt;This introductory book covers Windows Workflow Foundation at an introductory level for a current .NET developer. All code examples are explained so that you can read the book without a computer, or you can download the samples and work through them while you read.   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://www.windowsworkflow.net/"&gt;Participate in the Windows Workflow Foundation Community&lt;/a&gt;Join the community of developers building workflow based applications. The community web site includes forums, downloads and many other interesting things.   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold"&gt;Microsoft Employee Workflow Centric Blogs&lt;/a&gt;Scott Woodgate: &lt;a href="http://blogs.msdn.com/scottwoo"&gt;http://blogs.msdn.com/scottwoo&lt;/a&gt; Paul Andrew: &lt;a href="http://blogs.msdn.com/pandrew"&gt;http://blogs.msdn.com/pandrew&lt;/a&gt;   &lt;br /&gt;&lt;a style="FONT-WEIGHT: bold" href="http://www.impactevents.com/bpiwf/overview.aspx"&gt;Come to the Business Process Integration &amp; Workflow Conference&lt;/a&gt;You are invited to our Business Process Integration &amp;amp; Workflow conference where we will have an entire track dedicated to Windows Workflow Foundation. This conference is October 4–7, 2005, in Redmond, Washington. It is open to Microsoft System Integration Partners and Customers accompanied by System Integration Partners. Partners should use the registration code "MSP-01" and customers should use the registration code "MSC-01". Space is limited; see the linked Web page for full details.&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112686389300800272?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112686389300800272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112686389300800272' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112686389300800272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112686389300800272'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/09/windows-workflow-foundation.html' title='Windows WorkFlow Foundation'/><author><name>Ahsan</name><uri>http://www.blogger.com/profile/12740497037200673524</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112642647035317998</id><published>2005-09-11T01:09:00.000-07:00</published><updated>2005-09-11T01:14:30.360-07:00</updated><title type='text'>Data Protection API in .NET 2.0</title><content type='html'>&lt;p&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;Protecting sensitive Data through Managed DPAPI&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;While developing a web or windows application, developers often make use of the web.config file to store sensitive data like passwords and connection strings. In most cases, this data is protected from unauthorized access for e.g. IIS forbidding the download of web.config file placed in the virtual directory where the application resides.&lt;br /&gt;&lt;br /&gt;The data in the config files should nevertheless be in encrypted format for the safe storage of username/passwords and connection strings. Most developers including me were quite intent to use the Cryptography classes provided in .NET to encrypt and decrypt the strings, but all or most of them require the management of public/ private key pairs which doesn't make life easier anyway.&lt;br /&gt;Using DPAPI (Data protection API) is thus a better option which provides automatic key management. This key management can be either based on the user's credentials or the machine.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;User Level Encryption&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;When using user level encryption, DPAPI generates a session key which is derived from the user's credentials and the optional entropy that is discussed later. This session key is then used to do the actual encryption. With user level encryption, the encryption and decryption should be performed by the same user.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Machine Level Encryption&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Machine level encryption (although not much secure) allows the encrypted data to be decrypted by any application running on the same machine. This can be used in a server scenario where there are no unauthorized logins.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Support in Previous Versions&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;.NET version 1.1 did not provide any wrappers to use the DPAPI hence we had to make use of DLLImport to import Crypt32.dll and use the APIs CryptProtectData and CryptUnprotectData for encryption and decryption respectively.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ProtectedData class in Whidbey&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Starting from version 2.0,  Whidbey provides a class called ProtectedData having two static members Protect and UnProtect. The signatures of these methods are:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#3366ff;"&gt;1. byte[] Protect(byte[] dataToEncrypt, byte[] optionalEntropy,&lt;br /&gt;DataProtectionScope scope)&lt;br /&gt;&lt;br /&gt;2.  byte[] UnProtect(byte[] dataToDecrypt, byte[] optionalEntropy,&lt;br /&gt;DataProtectionScope scope)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:arial;font-size:85%;"&gt; dataToEncrypt is the data to encrypt&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;font-size:85%;"&gt; optionalEntropy is an additional entropy added to the key generation step. Without knowing this byte array no one can decrypt the data.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Setting the scope to DataProtectionScope.CurrentUser allows user level encryption while DataProtectionScope.LocalMachine allows machine level encryption as discussed earlier.&lt;br /&gt; &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;DataProtectionPermission&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-size:85%;"&gt;Whidbey also provides with DataProtectionPermission that can be used to grant/deny permission to the code on the call stack for ProtectedData to work. This can be used to limit permission to only encrypting or decrypting the data or both.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code sample&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#33cc00;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;font-size:85%;color:#3366ff;"&gt;      static void Main()&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                        byte[] entropyBytes = new byte[] {0x00,0x01,0x23, 0x34,0x0A};&lt;br /&gt;                        byte[] myDataBytes;&lt;br /&gt;                        string myData = "My sensitive data";&lt;br /&gt;                        myDataBytes= System.Text.Encoding.Unicode.GetBytes(myData);&lt;br /&gt;                        byte[] encryptedData = ProtectedData.Protect(&lt;br /&gt;                                    myDataBytes,entropyBytes,DataProtectionScope.CurrentUser);&lt;br /&gt;&lt;br /&gt;                        //print the encrypted bytes&lt;br /&gt;                        ////////////////////////////&lt;br /&gt;&lt;br /&gt;                        //decrypt the data&lt;br /&gt;                        byte[] decryptedData = ProtectedData.UnProtect(&lt;br /&gt;                                    encryptedData,entropyBytes,DataProtectionScope.CurrentUser);&lt;br /&gt;&lt;br /&gt;                        //print the decrypted bytes which should be the same as myData&lt;br /&gt;                        ////////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;                        Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            }&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112642647035317998?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112642647035317998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112642647035317998' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112642647035317998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112642647035317998'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/09/data-protection-api-in-net-20.html' title='Data Protection API in .NET 2.0'/><author><name>Naveedullah</name><uri>http://www.blogger.com/profile/17409087879792172171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112635711271866184</id><published>2005-09-10T05:33:00.000-07:00</published><updated>2005-09-10T06:11:43.850-07:00</updated><title type='text'>Accessing LDAP from ASP.NET</title><content type='html'>This article will not only guide you how to access LDAP from asp.net application but it will also try to shed light on some of the issues you will face while accessing LDAP from web application. We have to take care of some security issues while accessing LDAP from asp.net. For winform application it’s not problematic but in web application we have to take into account impersonation also. My class contain two member variable&lt;br /&gt;&lt;br /&gt;private string _path;&lt;br /&gt;private string _filterAttribute&lt;br /&gt;&lt;br /&gt;Construtor of this will form path string which will be passed to while making DirectoryEntry object. Below is the code of constructor&lt;br /&gt;&lt;br /&gt;public LdapAuthentication(string domain)&lt;br /&gt;{&lt;br /&gt;_path = "GC://";&lt;br /&gt;string[] aSubdomain = domain.Split('.');&lt;br /&gt;foreach (string strDomain in aSubdomain)&lt;br /&gt;{&lt;br /&gt;_path += "DC=" + strDomain + ",";&lt;br /&gt;}&lt;br /&gt;_path = _path.Substring(0, _path.Length-1);&lt;br /&gt;}&lt;br /&gt;This will produce path of following format&lt;br /&gt;_path = "LDAP://DC=HO,DC=ABC-COMPANY,DC=COM"&lt;br /&gt;Now the gist of whole class is IsAuthenticated method which is&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Check if the provided information is authenticated or not&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="domain"&gt;Domain&lt;/param&gt;&lt;br /&gt;/// &lt;param name="username"&gt;user name to be verified&lt;/param&gt;&lt;br /&gt;/// &lt;param name="pwd"&gt;password corresponding to the user name&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;true in case of authentication else false&lt;/returns&gt;&lt;br /&gt;public bool IsAuthenticated(string domain, string username, string pwd)&lt;br /&gt;{&lt;br /&gt;string domainAndUsername = domain + @"\" + username;&lt;br /&gt;DirectoryEntry entry = new DirectoryEntry( _path, domainAndUsername, pwd);&lt;br /&gt;// Bind to the native AdsObject to force authentication.&lt;br /&gt;Object obj = entry.NativeObject;&lt;br /&gt;DirectorySearcher search = new DirectorySearcher(entry);&lt;br /&gt;search.Filter = "(SAMAccountName=" + username + ")";&lt;br /&gt;search.PropertiesToLoad.Add("cn");&lt;br /&gt;SearchResult result = search.FindOne();&lt;br /&gt;if(null == result)&lt;br /&gt;{&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;// Update the new path to the user in the directory&lt;br /&gt;_path = result.Path;&lt;br /&gt;_filterAttribute = (string)result.Properties["cn"][0];&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Previously I was using same function but then I came across some article which pointed out that FindOne method has memory leak under certain condition for example, it will produce memory leak if it wont find any result, therefore I would recommend you to replace findOne with findAll which is not buggy. Now the method will be like&lt;br /&gt;SearchResult result = null; using (SearchResultCollection src = search.FindAll()){ if (src.Count &gt; 0) result = src[0];}&lt;br /&gt;if (result != null){ // Update the new path to the user in the directory&lt;br /&gt;_path = result.Path;&lt;br /&gt;_filterAttribute = (string)result.Properties["cn"][0];&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This method will update the path string in case of success of authentication. Now the string will be like&lt;br /&gt;_path = "GC://CN=SAJWANI Rameez,OU=Users,OU=DUBAI,DC=ho,DC=cma-cgm,DC=com"&lt;br /&gt;We will also store cn property from LDAP which will be helpful in retrieving other information. Like email , last name etc.&lt;br /&gt;To find out FirstName we will use following method&lt;br /&gt;&lt;br /&gt;public string GetFirstName()&lt;br /&gt;{&lt;br /&gt;DirectoryEntry entry = new DirectoryEntry( _path);&lt;br /&gt;DirectorySearcher search = new DirectorySearcher(entry);&lt;br /&gt;search.Filter = "(cn=" + _filterAttribute + ")";&lt;br /&gt;search.PropertiesToLoad.Add("givenName");&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;SearchResult result = null; using (SearchResultCollection src = search.FindAll()){ if (src.Count &gt; 0) result = src[0];}&lt;br /&gt;if (result != null){ // Update the new path to the user in the directory&lt;br /&gt;return result.Properties["givenName"][0].ToString();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;catch&lt;br /&gt;{&lt;br /&gt;return "";&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Similarly to get email address we will use following:&lt;br /&gt;return result.Properties["mail"][0].ToString();&lt;br /&gt;In this way we can load any property we want. Now the real thing come to run this code under asp.net. One thing to remember is that we are connecting to LDAP by providing username and password we can also connect under the security context of the ASP.NET Web user.&lt;br /&gt;Before addressing the security issue we wil first look at how LDAP actually works.&lt;br /&gt;&lt;br /&gt;The Active Directory (AD) relies on the security mechanism of the Windows 2000 server. To access most information in the AD, you must provide credentials to the Windows 2000 server when requesting the AD information. The credentials you provide must be in a primary token, which just means that the IIS server has a password (not just a hash of the password) to pass to the AD.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Double-Hop Issue&lt;/strong&gt;&lt;br /&gt;The double-hop issue is when the ASPX page tries to use resources that are located on a server that is different from the IIS server. In our case, the first "hop" is from the web browser client to the IIS ASPX page; the second hop is to the AD. The AD requires a primary token. Therefore, the IIS server must know the password for the client to pass a primary token to the AD. If the IIS server has a secondary token, the NTAUTHORITY\ANONYMOUS account credentials are used. This account is not a domain account and has very limited access to the AD. The double-hop using a secondary token occurs, for example, when the browser client is authenticated to the IIS ASPX page by using NTLM authentication. In this example, the IIS server has a hashed version of the password as a result of using NTLM. If IIS turns around and passes the credentials to the AD, IIS is passing a hashed password. The AD cannot verify the password and, instead, authenticates by using the NTAUTHORITY\ANONYMOUS LOGON. On the other hand, if your browser client is authenticated to the IIS ASPX page by using Basic authentication, the IIS server has the client password and can make a primary token to pass to the AD. The AD can verify the password and does authenticate as the domain user.&lt;br /&gt;How to acquire Primary Token&lt;br /&gt;If the IIS server has a primary token to pass on, the IIS server can pass a primary token to the AD on behalf of the client requesting the ASPX page. To acquire a primary token by using ASPX, use one of the following methods.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Method A&lt;br /&gt;&lt;/strong&gt;When the Web.config file is set to identity impersonate="true"/ and authentication mode="Windows", use the Anonymous account with the following settings:&lt;br /&gt;On the ASPX page, set the security mechanism to Anonymous only.&lt;br /&gt;Clear the Allow IIS to control the password check box.&lt;br /&gt;Set the Anonymous account to be a domain user.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Method B&lt;br /&gt;&lt;/strong&gt;When Web.config and Machine.config are set as follows:&lt;br /&gt;When Web.config is set to identity impersonate="false"/ and authentication mode="Windows"&lt;br /&gt;When Machine.config is set to processModel username=Domain\username,password=secret&lt;br /&gt;If identity impersonate="false"/ in the Web.config file, the credentials of the Base process are used. When you supply a domain user and password, you make it possible for IIS to pass a primary token to the AD.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ASP.NET Base Account&lt;/strong&gt;&lt;br /&gt;By default, all ASP.NET applications run under the base process account, MACHINENAME\ASPNET. This is a local account that does not have access to objects in Active Directory. To access Active Directory by using the credentials that are passed to IIS, you must modify your Web.config file to contain the parameters identity impersonate="true" and authentication mode="Windows". The presence of these two parameters causes ASP.NET to run the code under the credentials that are passed to it by IIS.&lt;br /&gt;I case of my scenario I was using Form Base Authentication. All the user of my application are my intranet so for every request I was putting the principle object of that user in context. By using following line.&lt;br /&gt;&lt;br /&gt;// This principal will flow throughout the request.&lt;br /&gt;GenericPrincipal principal = new GenericPrincipal(id, null);&lt;br /&gt;// Attach the new principal object to the current HttpContext object&lt;br /&gt;Context.User = principal;&lt;br /&gt;&lt;br /&gt;Some time LDAP connection works from local host but i wont if i will be access from remot machine in that case make sure that integrated login is working.&lt;br /&gt;&lt;br /&gt;Note : In order to make sure the Integrated Login works with AD you need to two specials things Number &lt;br /&gt;1: Go the domain controller of your webserver. Go to the Computers Container and Find your webserver. Go in properties and check the allow delegation option. You may have to restart the computer.&lt;br /&gt;- Numebr 2 Make sure the IntegratedLogin is enabled on the InternetExplorer. You will find this option in the Tools --&gt; Internet Options --&gt; Advanced option&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Reference.&lt;br /&gt;http://support.microsoft.com/default.aspx?scid=kb;en-us;329986&lt;br /&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/active_directory_authentication_from_asp__net.asp&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112635711271866184?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112635711271866184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112635711271866184' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112635711271866184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112635711271866184'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/09/accessing-ldap-from-aspnet.html' title='Accessing LDAP from ASP.NET'/><author><name>rameez</name><uri>http://www.blogger.com/profile/16767738858958412178</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112581051981579196</id><published>2005-09-03T22:08:00.000-07:00</published><updated>2005-09-03T22:08:39.820-07:00</updated><title type='text'>XML documentation in Visual Basic.NET applications</title><content type='html'>By default VB.Net in VS.net is missing support for automated generation of the documentation from with in the source, Like &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfTagsForDocumentationComments.asp"&gt;Recommended Tags for Documentation Comments&lt;/a&gt;.&lt;br /&gt;Here 'VBCommenter' PowerToy from the Got Dot Net Web site can help us. With VBCommenter plug-in, they can create XML documentation as they are writing code.&lt;br /&gt;To use this facility, it's first necessary to install VBCommenter. The download is a ZIP file that includes a standard Setup.exe file with an accompanying .msi file; it's trivial to unpack and install and should take no more than two minutes. Configure VBCommenter settings from the Tools VBCommenter Options menu. Here, make sure the checkboxes for both "Create .xml files when projects are built" and "Insert XML comments in source" are checked. &lt;br /&gt;Once the plug-in is running and configured, simply key three apostrophes into the Start Page for any class definition, property, member variable, or method.&lt;br /&gt;&lt;br /&gt;Because documenting as you go is the best way to make sure all the nuances of the code are captured, this technique (and the VBCommenter tool) are highly recommended for those seeking an easy way to add structured documentation to their work.&lt;br /&gt;&lt;br /&gt;For a bit advance work, VBCommenter can be customized as described here : &lt;a href="http://www.15seconds.com/issue/040302.htm"&gt;Customizing The VBCommenter Power Toy&lt;/a&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112581051981579196?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112581051981579196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112581051981579196' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112581051981579196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112581051981579196'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/09/xml-documentation-in-visual-basicnet.html' title='XML documentation in Visual Basic.NET applications'/><author><name>Habib Qureshi</name><uri>https://profiles.google.com/113730817373262408436</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-ZWt3OfX7_XY/AAAAAAAAAAI/AAAAAAAAAQA/onuiVxb4d8Q/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112574664040279866</id><published>2005-09-03T04:24:00.000-07:00</published><updated>2005-09-03T04:24:00.406-07:00</updated><title type='text'>MSDN TV Episode talks about "Data Access in ASP.NET 2.0"</title><content type='html'>&lt;a href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20050901ASPNETBM/manifest.xml"&gt;&lt;br /&gt;&lt;image src="http://msdn.microsoft.com/msdntv/episodes/en/20050901ASPNETBM/BradleyMillington.jpg"/&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20050901ASPNETBM/manifest.xml"&gt;&lt;br /&gt;MSDN TV: Data Access in ASP.NET 2.0&lt;/a&gt;: &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Data Access in ASP.NET 2.0&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20050901ASPNETBM/manifest.xml"&gt;&lt;br /&gt;Bradley Millington shows how to build a data-driven Web site in ASP.NET 2.0 and Visual Studio 2005. &lt;br /&gt;Learn how to build a database from scratch using Visual Studio built-in support for SQL Server 2005 Express, &lt;br /&gt;then retrieve and render the database contents using the new data controls in ASP.NET. &lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;Hammad Rajjoub,&lt;br /&gt;MVP (Windows Server System - XML Web Services),&lt;br /&gt;User Group Leader - Dot Net Wizards (http://dotnetwizards.blogspot.com),&lt;br /&gt;Chariman UG Relations Committee (http://www.inetapakistan.org),&lt;br /&gt;Member Speakers Bureau (http://mea.ineta.org) &lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112574664040279866?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112574664040279866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112574664040279866' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112574664040279866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112574664040279866'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/09/msdn-tv-episode-talks-about-data.html' title='MSDN TV Episode talks about &quot;Data Access in ASP.NET 2.0&quot;'/><author><name>Hammad</name><uri>http://www.blogger.com/profile/15134916221126439154</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_ySWRHLE5dUA/RjMuR3xILFI/AAAAAAAAABo/vV87yWYuWfk/s320/dilbert.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112549500482170006</id><published>2005-08-31T06:30:00.000-07:00</published><updated>2005-08-31T06:30:07.700-07:00</updated><title type='text'>Web Services and other distributed technologies: Developing Distributed Services Today</title><content type='html'>&lt;a href="http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnwebsrv/html/dsgprescriptiveguidance.asp"&gt;Web Services and other distributed technologies: Developing Distributed Services Today&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This paper provides guidance on how to best use Microsoft Web service and distributed systems technologies in order to build distributed, service-oriented systems using today's platform. The impact of future technologies such as 'Indigo' is considered, and how Microsoft products such as BizTalk Server, SQL Server Notification Services, and Host Integration Server are positioned in this space&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112549500482170006?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112549500482170006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112549500482170006' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112549500482170006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112549500482170006'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/08/web-services-and-other-distributed.html' title='Web Services and other distributed technologies: Developing Distributed Services Today'/><author><name>Hammad</name><uri>http://www.blogger.com/profile/15134916221126439154</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_ySWRHLE5dUA/RjMuR3xILFI/AAAAAAAAABo/vV87yWYuWfk/s320/dilbert.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112513972114401106</id><published>2005-08-27T03:25:00.000-07:00</published><updated>2005-08-28T23:33:40.066-07:00</updated><title type='text'>Script Callbacks in ASP.NET</title><content type='html'>One of the many feature of ASP.NET 2.0 is that it allow us to call to server event from client side with out letting the page to post back and refresh. This mechanism is implemented through callbacks. This feature become very handy when you have very rich UI where refresh and post back become very hectic. For example when we have tree view control on page and we donot want our rich UI page to be post back on every expand or collaps in that scenario one option can be to implement ASP.NET Scripts callbacks. In this way request will be send asynchronously to the server and client will continue to work.&lt;br /&gt;&lt;br /&gt;Many implementation has been given for out-of-band patterns i-e calling function from client side to server without letting the whole page to refresh. Few years ago microsoft realeased a interesting technology callled Remote Scripting. It uses some client side scipt to trigger a java language applet which in turns open the sockets to the destination URL. the remote URL must be a classic ASP page that include a call to server side layer of Remote scripting and exposes an object with a given name - public_description. The return value of call must be a string.&lt;br /&gt;&lt;br /&gt;Another implementation of out-of-bond pattern is webservice , We know that we can call websevice through java script also. For this we have to use webservice.htc. But this behaviour is limit to only Internet Explorer 5.0 and higher version. In this case we use XmlHttp instead of java applet. Now MS tried to solve this problem in ASP.net 2.0. One good thing of this is, its fully integrated with framework. In ASP.NET 2.0 the scripting model of the page object is enriched with callback abilities that provide ASP.NET specific implementation of a kind of remote scripting.&lt;br /&gt;&lt;br /&gt;What ever the implementation is, the pattern of out of bond is same. Which is ,new http channel for sending and getting the response is setup in parallel. the new request should be invisible to the user to avoid any interference with the displayed page. Finally the response you get from this invisible request must be merged with the current page through dynamic changes to the document object model (DOM) of the page.&lt;br /&gt;&lt;br /&gt;To use Asp.net 2.0 script callbacks, you define a trigger element in the page (not a submit button) and bind it to some javascript code. this code will retrieve input data from the current page input fields and prepare a call to a system-provided script function name WebForm_DoCallback in Beta1. This function is expected (in the final release) to open the HTTP connection to the specific remote ASP.NET page. The ASP.NET runtime detects a callback invocation and executes a particular method on the page. The return value of the server-side method is passed back to the client as the response to the previous request. On the client, the response gets passed to a user-defined javascript callback function that can then update the user interface via DHTML. The bottom line is that a round-trip still occures, but the page is not fully refreshed. More importantly, the user can continue working with the controls in the page while the parallel request is served.&lt;br /&gt;&lt;br /&gt;Let us now look a small implementation of it.The remote invocation begins by calling a javascript function WebForm_DoCallback , it is built in function. To call a javascript function It is essentail that clickable element not be a submit button. Therefore we cannot render it using asp:button &lt;?xml:namespace prefix = asp /&gt;&lt;asp:button&gt;tag because such a server control outputs the submit markup. Therefore we will use normal html button tag.&lt;br /&gt;AS expected the ASP.NET runtime takes care of the request and begin processing it. By looking at the request header, body and viewstate fields it will determine the postback mode. If its figure out that page is being invodked on an out-of-band call , it will set IsCallback property to ture. Next it will figure out the callback mode by looking the _CALLBACK entry in request collection . If such entry exists then runtime conclude that callback invocation is being made. Now runtime checks if the page implements ICallbackEventHandler interface , it invokes the RaiseCallbackEvent method on the interface and prepares the response from the result of the call. A page that implements this interface have following directive&lt;br /&gt;&lt;%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %&gt;&lt;br /&gt;to add function to html button we will add runat server tag to it so that it will be available in code behind.&lt;br /&gt;&lt;br /&gt;The remote invocation begins when a call is made to a built-in JavaScript function named WebForm_DoCallback. You don't necessarily need to know the name and signature of this function, as you can get it from a new member of the Page class—the etCallbackEventReference method. So in code behind we will add following&lt;/asp:button&gt;&lt;br /&gt;&lt;asp:button&gt;&lt;br /&gt;string js = GetCallbackEventReference(this, "document.all['cboEmployees'].value", "UpdateEmployeeViewHandler", "null", "null");btn.Attributes["onclick"] = String.Format("javascript:{0}", js); &lt;/asp:button&gt;&lt;br /&gt;&lt;asp:button&gt;&lt;br /&gt;actual declaration of docallback is&lt;br /&gt;function WebForm_DoCallback( eventTarget, eventArgument, eventCallback, context, errorCallback) { •••}&lt;br /&gt;&lt;br /&gt;In RaiseEventHandler we will write all the code whatever to return to the client. for example&lt;br /&gt;&lt;br /&gt;public virtual string RaiseCallbackEvent (string eventArgument)&lt;br /&gt;{ // Get more info about the specified employee&lt;br /&gt;int empID = Convert.ToInt32 (eventArgument);&lt;br /&gt;EmployeesManager empMan = new EmployeesManager();&lt;br /&gt;EmployeeInfo emp = empMan.GetEmployeeDetails (empID);&lt;br /&gt;string[] buf = new string[6];&lt;br /&gt;buf[0] = emp.ID.ToString ();&lt;br /&gt;buf[1] = emp.FirstName;&lt;br /&gt;buf[2] = emp.LastName;&lt;br /&gt;buf[3] = emp.Title;&lt;br /&gt;buf[4] = emp.Country;&lt;br /&gt;buf[5] = emp.Notes;&lt;br /&gt;return String.Join(",", buf);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;and in javascript function we will take all back the data and update the UI Component as needed. the return value contain string. This string can actually contain everything you want and need, including XML data or Base64 data, comma-separated values, dates, numbers, and so forth.You can use callbacks to update individual elements of a page , such as a chart or a panel, provide different views of the same data, download additional information on demand, or auto-fill one or more fields, In particular, the ASP.NET2.0 TreeView control uses script callback extensively to implement its expand/collapse features and GridView control uses callbacks to page and sort without explicit postback.&lt;br /&gt;&lt;/asp:button&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112513972114401106?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112513972114401106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112513972114401106' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112513972114401106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112513972114401106'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/08/script-callbacks-in-aspnet.html' title='Script Callbacks in ASP.NET'/><author><name>rameez</name><uri>http://www.blogger.com/profile/16767738858958412178</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112477860687327049</id><published>2005-08-22T22:33:00.000-07:00</published><updated>2005-08-22T23:30:18.340-07:00</updated><title type='text'>DataAccess layer with Dataset</title><content type='html'>There have been few approaches that we used to follow while developing the Data Access Layer&lt;br /&gt;&lt;br /&gt;1) Create Entity Classes and directly call Database Code to access the data&lt;br /&gt;2) Introduce a DB independent data access Layer which in turn call respective Database Code to access the data. This also involves creating command and parameters, connections on higher level.&lt;br /&gt;&lt;br /&gt;But the common thing is that there isnt much abstraction in between business and the data acces layer and we have to write too much lines of code for the CRUD operations. Also everytime we make a new application there is some dependencies created.&lt;br /&gt;&lt;br /&gt;I personally believe in this approach which i am mentioning below. I am just presenting the idea for which implementation is upon the followers.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;More Exhaustive Use of dataset&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;First thing an application should follow is to use Dataset as a medium of data transfer. Every layer should have supportive methods to get/set the data in Dataset form. This doesnt mean that we should not make Business Layer entities and abstracted methods. The only thing is to keep this approach in parallel to your normal archtectural design.&lt;br /&gt;&lt;br /&gt;For each entity you should have a DataTable mapped to database table and for each conceptual module you should have a DataSet (my recommendation is to use a Typed Dataset). So we have a Dataset which contain several tables of the related module.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How To make things Simple and Generic&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Now the DataAcces Layer must solely should work on Dataset. As we know that Dataset is the projection of a relational database, so it contains all those elements required for a Database operation.&lt;br /&gt;&lt;br /&gt;Question is how it simplifies things?&lt;br /&gt;Let us assume that each entity have to be saved in database and we have a datatable for each entity. Now what the only thing a programmer has to do is to check the rowstate of every row (Added,Modifed,Deleted) and do the appropiate operation on it. This will involve traversing all the DataTables in the DataSet and all the rows in the DataTable. This will also help to apply transactions more easily as the whole operation is done from a single entry point i.e save method.&lt;br /&gt;&lt;br /&gt;e.g We have a order module. Order has a Dataset which contain order detail and its product. Assume we want to save the Order to database. Now your save function will take a dataset input which will contain all the details of the order. It will traverse each tables (OrderDetail,OrderProduct) and each row of these tables. For each row we will check the status of the row.&lt;br /&gt;If it is Added, we will call insert procedure for the entity&lt;br /&gt;If it is Updated, we will call update procedure for the entity&lt;br /&gt;same as for delete.&lt;br /&gt;&lt;br /&gt;If you understand me correctly what this mean is that our Data Access Layer will only contain one save method for the whole application. As this save method is enough capable for doing all the saving operations to the database.&lt;br /&gt;&lt;br /&gt;Now questioning its Genericity, this approach is using Dataset as it main data transfer medium and dataset is a part of .Net framework. Dataset itself contain enough information to cater all types of database operations. So, it is clear enough to use this Data Access Layer in any of your application provided application should be based upon Dataset.&lt;br /&gt;&lt;br /&gt;The amount of code will be reduced to only one function for each operation which will make it simple and highly manageable.&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112477860687327049?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112477860687327049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112477860687327049' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112477860687327049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112477860687327049'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/08/dataaccess-layer-with-dataset.html' title='DataAccess layer with Dataset'/><author><name>Ahsan</name><uri>http://www.blogger.com/profile/12740497037200673524</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112471363940838145</id><published>2005-08-22T05:23:00.000-07:00</published><updated>2005-08-22T05:27:19.413-07:00</updated><title type='text'>hello world</title><content type='html'>why &lt;span style="font-style: italic;"&gt;Dotnet&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;Dubai&lt;/span&gt; then?&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112471363940838145?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112471363940838145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112471363940838145' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112471363940838145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112471363940838145'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/08/hello-world.html' title='hello world'/><author><name>Habib Qureshi</name><uri>https://profiles.google.com/113730817373262408436</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-ZWt3OfX7_XY/AAAAAAAAAAI/AAAAAAAAAQA/onuiVxb4d8Q/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112469571692869325</id><published>2005-08-22T00:27:00.000-07:00</published><updated>2005-08-22T00:28:36.933-07:00</updated><title type='text'>Encryption</title><content type='html'>&lt;p&gt;Employ the RSA encryption tools in .NET to protect your important data. RSA is a solution to digital privacy; just run your data through the cryptoservice and nobody can break the code. You can functionally guarantee that data is safe from prying eyes (unless someone gets hold of the private key). This article explains the uses of RSA and demonstrates exactly how to employ it in your VB.NET applications. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.devx.com/security/Article/17455"&gt;http://www.devx.com/security/Article/17455&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112469571692869325?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112469571692869325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112469571692869325' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112469571692869325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112469571692869325'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/08/encryption.html' title='Encryption'/><author><name>Ahsan</name><uri>http://www.blogger.com/profile/12740497037200673524</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112469381781280742</id><published>2005-08-21T23:56:00.000-07:00</published><updated>2005-08-21T23:56:57.813-07:00</updated><title type='text'>Security Practices: ASP.NET 2.0 Security Practices at a Glance</title><content type='html'>This module presents a set of consolidated practices designed to address ASP.NET version 2.0 security issues. The answers and recommendations presented in this module are tight distillations designed to supplement the companion modules and additional guidance. The practices are organized by various categories that represent those areas where mistakes are most often made. This module includes an index of practices&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/PAGPractices0001.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/PAGPractices0001.asp&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112469381781280742?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112469381781280742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112469381781280742' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112469381781280742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112469381781280742'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/08/security-practices-aspnet-20-security.html' title='Security Practices: ASP.NET 2.0 Security Practices at a Glance'/><author><name>Ahsan</name><uri>http://www.blogger.com/profile/12740497037200673524</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112469372477534954</id><published>2005-08-21T23:54:00.000-07:00</published><updated>2005-08-21T23:55:24.776-07:00</updated><title type='text'>101 Samples to Learn 2.0</title><content type='html'>101 Samples, in both Visual Basic and C#, featuring many of the new features available with Visual Studio 2005 and the .NET Framework 2.0&lt;br /&gt;&lt;br /&gt;&lt;a href="http://lab.msdn.microsoft.com/vs2005/downloads/101samples/default.aspx"&gt;http://lab.msdn.microsoft.com/vs2005/downloads/101samples/default.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112469372477534954?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112469372477534954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112469372477534954' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112469372477534954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112469372477534954'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/08/101-samples-to-learn-20_21.html' title='101 Samples to Learn 2.0'/><author><name>Ahsan</name><uri>http://www.blogger.com/profile/12740497037200673524</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15660375.post-112469184886395175</id><published>2005-08-21T23:21:00.000-07:00</published><updated>2005-08-21T23:24:08.866-07:00</updated><title type='text'>Welcome</title><content type='html'>Welcome To DotNetDubai!&lt;br /&gt;&lt;br /&gt;This blog is intended for all .Net developers to share, help , guide and learn the techonology.&lt;div class="blogger-post-footer"&gt;Microsoft .Net Xml C# VB.NET Biztalk CMS SPS SQL SERVER CRM&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15660375-112469184886395175?l=dotnetdubai.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnetdubai.blogspot.com/feeds/112469184886395175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=15660375&amp;postID=112469184886395175' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112469184886395175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15660375/posts/default/112469184886395175'/><link rel='alternate' type='text/html' href='http://dotnetdubai.blogspot.com/2005/08/welcome.html' title='Welcome'/><author><name>Ahsan</name><uri>http://www.blogger.com/profile/12740497037200673524</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
