<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:gd="http://schemas.google.com/g/2005" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;D0cHQH87cSp7ImA9WhdbE08.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285</id><updated>2011-10-11T14:53:51.109+05:30</updated><title>Challa DotNet FAQ's Blog</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://challadotnetfaq.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>82</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/ChallaDotnetFaqsBlog" /><feedburner:info uri="challadotnetfaqsblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;A0MNSHcyeyp7ImA9WhdbEk4.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-7103764986904548220</id><published>2011-10-10T15:08:00.001+05:30</published><updated>2011-10-10T15:08:19.993+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-10T15:08:19.993+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Sql Server" /><title>How to Optimize Stored Procedure in sql server</title><content type="html">&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:WordDocument&gt;
  &lt;w:View&gt;Normal&lt;/w:View&gt;
  &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
  &lt;w:PunctuationKerning/&gt;
  &lt;w:ValidateAgainstSchemas/&gt;
  &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
  &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
  &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
  &lt;w:Compatibility&gt;
   &lt;w:BreakWrappedTables/&gt;
   &lt;w:SnapToGridInCell/&gt;
   &lt;w:WrapTextWithPunct/&gt;
   &lt;w:UseAsianBreakRules/&gt;
   &lt;w:DontGrowAutofit/&gt;
  &lt;/w:Compatibility&gt;
  &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
 &lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
 &lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;img src="http://img2.blogblog.com/img/video_object.png" style="background-color: #b2b2b2; " class="BLOGGER-object-element tr_noresize tr_placeholder" id="ieooui" data-original-id="ieooui" /&gt;
&lt;style&gt;
st1\:*{behavior:url(#ieooui) }
&lt;/style&gt;
&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;

&lt;div style="margin-left: 1in; text-indent: -0.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt;"&gt;&lt;span&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN"&gt;Include
SET NOCOUNT ON statement. &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 1in; text-indent: -0.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt;"&gt;&lt;span&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN"&gt;Use
schema name with object name. &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 1in; text-indent: -0.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt;"&gt;&lt;span&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN"&gt;Do
not use the prefix “sp_” in the stored procedure name. &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 1in; text-indent: -0.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt;"&gt;&lt;span&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN"&gt;Use
IF EXISTS (SELECT 1) instead of (SELECT *). &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 1in; text-indent: -0.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt;"&gt;&lt;span&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN"&gt;Use
the sp_executesql stored procedure instead of the EXECUTE statement. &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 1in; text-indent: -0.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt;"&gt;&lt;span&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN"&gt;Try
to avoid using SQL Server cursors whenever possible. &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 1in; text-indent: -0.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt;"&gt;&lt;span&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN"&gt;Keep
the Transaction as short as possible. &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 1in; text-indent: -0.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt;"&gt;&lt;span&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN"&gt;Use
TRY-Catch for error handling. &lt;/span&gt;&lt;/div&gt;
&lt;ul type="disc"&gt;
&lt;li class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span lang="EN" style="font-variant: normal ! important;"&gt;Include SET NOCOUNT ON
     statement:&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;&lt;b&gt; &lt;/b&gt;With every SELECT and DML
     statement, the SQL server returns a message that indicates the number of
     affected rows by that statement. This information is mostly helpful in
     debugging the code, but it is useless after that. By setting SET NOCOUNT
     ON, we can disable the feature of returning this extra information. For
     stored procedures that contain several statements or contain Transact-SQL
     loops, setting SET NOCOUNT to ON can provide a significant performance
     boost because network traffic is greatly reduced. &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="MsoNormal" style="margin-left: 0.5in;"&gt;
&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;CREATE&amp;nbsp;PROC &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;dbo.ProcName&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;AS&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;SET &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;NOCOUNT &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;ON&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;;&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--Procedure&amp;nbsp;code&amp;nbsp;here&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;SELECT &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;column1 &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;FROM &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;dbo.TblTable1&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--&amp;nbsp;Reset&amp;nbsp;SET&amp;nbsp;NOCOUNT&amp;nbsp;to&amp;nbsp;OFF&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;SET &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;NOCOUNT &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;OFF&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;;&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;GO &lt;/span&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul type="disc"&gt;
&lt;li class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span lang="EN" style="font-variant: normal ! important;"&gt;Use schema name with object name:&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt; The object name is qualified if used with schema
     name. Schema name should be used with the stored procedure name and with
     all objects referenced inside the stored procedure. This help in directly
     finding the complied plan instead of searching the objects in other
     possible schema before finally deciding to use a cached plan, if
     available. This process of searching and deciding a schema for an object
     leads to COMPILE lock on stored procedure and decreases the stored procedure’s
     performance. Therefore, always refer the objects with qualified name in
     the stored procedure like &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="MsoNormal" style="margin-left: 0.5in;"&gt;
&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;SELECT &lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;* &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;FROM &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;dbo.MyTable &lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--&amp;nbsp;Preferred&amp;nbsp;method&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--&amp;nbsp;Instead&amp;nbsp;of&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;SELECT &lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;* &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;FROM &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;MyTable &lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--&amp;nbsp;Avoid&amp;nbsp;this&amp;nbsp;method&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--And&amp;nbsp;finally&amp;nbsp;call&amp;nbsp;the&amp;nbsp;stored&amp;nbsp;procedure&amp;nbsp;with&amp;nbsp;qualified&amp;nbsp;name&amp;nbsp;like:&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;EXEC &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;dbo.MyProc &lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--&amp;nbsp;Preferred&amp;nbsp;method&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--Instead&amp;nbsp;of&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;EXEC &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;MyProc &lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--&amp;nbsp;Avoid&amp;nbsp;this&amp;nbsp;method&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul type="disc"&gt;
&lt;li class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span lang="EN" style="font-variant: normal ! important;"&gt;Do not use the prefix “sp_” in the stored
     procedure name&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;&lt;b&gt;: &lt;/b&gt;If a stored procedure name
     begins with “SP_,” then SQL server first searches in the master database
     and then in the current session database. Searching in the master database
     causes extra overhead and even a wrong result if another stored procedure
     with the same name is found in master database. &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul type="disc"&gt;
&lt;li class="MsoNormal"&gt;&lt;b&gt;&lt;span lang="EN" style="font-variant: normal ! important;"&gt;Use IF EXISTS (SELECT 1) instead of (SELECT *):&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt; To check the existence of a record in another table, we uses the
     IF EXISTS clause. The IF EXISTS clause returns True if any value is
     returned from an internal statement, either a single value “1” or all
     columns of a record or complete recordset. The output of the internal
     statement is not used. Hence, to minimize the data for processing and
     network transferring, we should use “1” in the SELECT clause of an
     internal statement, as shown below: &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="MsoNormal" style="margin-left: 0.5in;"&gt;
&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;IF &lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;EXISTS&amp;nbsp;(&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;SELECT &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;1 &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;FROM &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;sysobjects &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;WHERE &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;name &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;= &lt;/span&gt;&lt;span lang="EN" style="color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;'MyTable' &lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;AND &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;type &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;= &lt;/span&gt;&lt;span lang="EN" style="color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;'U'&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;)&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;ul type="disc"&gt;
&lt;li class="MsoNormal"&gt;&lt;span lang="EN" style="font-variant: normal ! important;"&gt;&lt;b&gt;Use the sp_executesql stored procedure instead of the EXECUTE
     statement&lt;/b&gt;.&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
     The sp_executesql stored procedure supports parameters. So, using the
     sp_executesql stored procedure instead of the EXECUTE statement improve
     the re-usability of your code. The execution plan of a dynamic statement
     can be reused only if each and every character, including case, space,
     comments and parameter, is same for two statements. For example, if we
     execute the below batch: &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="MsoNormal" style="margin-left: 0.5in;"&gt;
&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;DECLARE &lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Query &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;VARCHAR&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;(&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;100&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;)&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;DECLARE &lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Age &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;INT&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;SET &lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Age &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;= &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;25&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;SET &lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Query &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;= &lt;/span&gt;&lt;span lang="EN" style="color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;'SELECT&amp;nbsp;*&amp;nbsp;FROM&amp;nbsp;dbo.tblPerson&amp;nbsp;WHERE&amp;nbsp;Age&amp;nbsp;=&amp;nbsp;'
&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;+ &lt;/span&gt;&lt;span lang="EN" style="color: magenta; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;CONVERT&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;(&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;VARCHAR&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;(&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;3&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;),&lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Age&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;)&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;EXEC &lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;(&lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Query&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;)&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: 0.5in;"&gt;
&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;If we again execute the above batch
using different @Age value, then the execution plan for SELECT statement
created for @Age =25 would not be reused. However, if we write the above batch
as given below,&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: 0.5in;"&gt;
&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;DECLARE &lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Query &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;NVARCHAR&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;(&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;100&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;)&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;SET &lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Query &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;= &lt;/span&gt;&lt;span lang="EN" style="color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;N'SELECT&amp;nbsp;*&amp;nbsp;FROM&amp;nbsp;dbo.tblPerson&amp;nbsp;WHERE&amp;nbsp;Age&amp;nbsp;=&amp;nbsp;@Age'&lt;/span&gt;&lt;span lang="EN" style="color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;EXECUTE &lt;/span&gt;&lt;span lang="EN" style="color: darkred; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;sp_executesql &lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Query&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;, &lt;/span&gt;&lt;span lang="EN" style="color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;N'@Age&amp;nbsp;int'&lt;/span&gt;&lt;span lang="EN" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;, &lt;/span&gt;&lt;span lang="EN" style="color: #434343; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;@Age &lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;= &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;25&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: 0.5in; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;the compiled plan of this SELECT
statement will be reused for different value of @Age parameter. The reuse of
the existing complied plan will result in improved performance.&lt;/span&gt;&lt;/div&gt;
&lt;ul type="disc"&gt;
&lt;li class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span lang="EN" style="font-variant: normal ! important;"&gt;Try to avoid using SQL Server cursors whenever
     possible:&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt; Cursor uses a lot of resources
     for overhead processing to maintain current record position in a recordset
     and this decreases the performance. If we need to process records
     one-by-one in a loop, then we should use the WHILE clause. Wherever
     possible, we should replace the cursor-based approach with SET-based
     approach. Because the SQL Server engine is designed and optimized to
     perform SET-based operation very fast. Again, please note cursor is also a
     kind of WHILE Loop. &lt;/span&gt;&lt;/li&gt;
&lt;li class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span lang="EN" style="font-variant: normal ! important;"&gt;Keep the Transaction as short as possible:&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt; The length of transaction affects blocking and
     deadlocking. Exclusive lock is not released until the end of transaction.
     In higher isolation level, the shared locks are also aged with
     transaction. Therefore, lengthy transaction means locks for longer time
     and locks for longer time turns into blocking. In some cases, blocking
     also converts into deadlocks. So, for faster execution and less blocking,
     the transaction should be kept as short as possible. &lt;/span&gt;&lt;/li&gt;
&lt;li class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span lang="EN" style="font-variant: normal ! important;"&gt;Use TRY-Catch for error handling&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;&lt;b&gt;: &lt;/b&gt;Prior to SQL server 2005 version code for error
     handling, there was a big portion of actual code because an error check
     statement was written after every t-sql statement. More code always
     consumes more resources and time. In SQL Server 2005, a new simple way is
     introduced for the same purpose. The syntax is as follows: &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="MsoNormal" style="margin-left: 0.5in;"&gt;
&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;BEGIN &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;TRY&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--Your&amp;nbsp;t-sql&amp;nbsp;code&amp;nbsp;goes&amp;nbsp;here&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;END &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;TRY&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;BEGIN &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;CATCH&lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;--Your&amp;nbsp;error&amp;nbsp;handling&amp;nbsp;code&amp;nbsp;goes&amp;nbsp;here&lt;/span&gt;&lt;span lang="EN" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;END &lt;/span&gt;&lt;span lang="EN" style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt; font-variant: normal ! important; font-weight: normal;"&gt;CATCH&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal ! important; font-weight: normal;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-7103764986904548220?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6O7E539AKMbnw8h0mvwSGXlPWFA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6O7E539AKMbnw8h0mvwSGXlPWFA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6O7E539AKMbnw8h0mvwSGXlPWFA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6O7E539AKMbnw8h0mvwSGXlPWFA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/ol-DB6g-3_M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/7103764986904548220/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=7103764986904548220" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/7103764986904548220?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/7103764986904548220?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/ol-DB6g-3_M/how-to-optimize-stored-procedure-in-sql.html" title="How to Optimize Stored Procedure in sql server" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/10/how-to-optimize-stored-procedure-in-sql.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8FQng7fip7ImA9WhdUF0w.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-7820785627303714113</id><published>2011-10-04T14:12:00.000+05:30</published><updated>2011-10-04T14:13:33.606+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-04T14:13:33.606+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Sql Server" /><title>Best Sql Server Interview Questions 2000/2005/2008 : Part 1</title><content type="html">&lt;br /&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;u&gt;&lt;span style="color: red;"&gt;Difference between DBMS and RDBMS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;u&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-left: 0.5in; width: 590px;"&gt;&lt;tbody&gt;
&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;&lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;DBMS – &lt;/b&gt;Data Base Management
  System&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;RDBMS –&lt;/b&gt;Relational Data Base
  Management System or Relational DBMS&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 1;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;DBMS has to be persistent, that is it should be accessible when the
  program created the data ceases to exist or even the application that created
  the data restarted. A DBMS also has to provide some uniform methods
  independent of a specific application for accessing the information that is
  stored.&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;RDBMS adds the additional condition that the system supports a tabular
  structure for the data, with enforced relationships between the tables. This
  excludes the databases that don’t support a tabular structure or don’t
  enforce relationships between tables.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 2;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;DBMS does not impose any constraints or security with regard to data
  manipulation it is user or the programmer responsibility to ensure the ACID
  PROPERTY of the database&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;RDBMS defines the integrity constraint for the purpose of holding ACID
  PROPERTY. RDBMS may be or may not be Client Server Database System.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 3; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;Ex: DBMS – File System, XML&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;Ex: RDBMS – SQL Server, Oracle&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;u&gt;&lt;span style="color: red;"&gt;Difference between &lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;u&gt;&lt;span lang="EN" style="color: red;"&gt;Normalization
and De-normalization&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;u&gt;&lt;span lang="EN" style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-left: 0.5in; width: 590px;"&gt;
 &lt;tbody&gt;
&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" style="text-align: center;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN"&gt;Normalization&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" style="text-align: center;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN"&gt;De-normalization&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 1;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;span lang="EN"&gt;Database normalization is a
  data design and organization process applied to data structures based on
  rules that help building relational databases. &lt;i style="mso-bidi-font-style: normal;"&gt;In relational database design, the process of organizing data to
  minimize redundancy is called normalization&lt;/i&gt;. Normalization usually
  involves dividing a database into two or more tables and defining
  relationships between the tables. The objective is to isolate data so that
  additions, deletions, and modifications of a field can be made in just one
  table and then propagated through the rest of the database via the defined
  relationships.&lt;/span&gt;&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span lang="EN"&gt;De-normalization is the process of attempting to optimize the performance
  of a database by adding redundant data.&lt;/span&gt;&lt;/i&gt;&lt;span lang="EN"&gt; It is sometimes necessary because current DBMSs
  implement the relational model poorly. A true relational DBMS would allow for
  a fully normalized database at the logical level, while providing physical storage
  of data that is tuned for high performance. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 2; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;span lang="EN"&gt;Normalization is a technique to
  move from lower to higher normal forms of database modeling.&lt;/span&gt;&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;span lang="EN"&gt;De-normalization is a technique
  to move from higher to lower normal forms of database modeling in order to speed
  up database access.&lt;/span&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN" style="color: red;"&gt;3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN" style="color: red;"&gt;What is Difference between DELETE and TRUNCATE Commands?&lt;u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN" style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-left: 0.5in; width: 590px;"&gt;
 &lt;tbody&gt;
&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;DELETE&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;TRUNCATE&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 1;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;Delete command removes the rows from a table on the basis of the condition
  that we provide with a WHERE clause.&lt;br /&gt;
&lt;br /&gt;
DELETE can be used with or without a WHERE clause&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;Truncate will actually remove all the rows from a table, and there will be
  no data in the table after we run the truncate command.&lt;br /&gt;
&lt;br /&gt;
Can’t apply where condition on Truncate&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 2;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;DELETE removes rows one at a time and records an entry in the transaction
  log for each deleted row.&lt;br /&gt;
&lt;br /&gt;
Delete is slower than Truncate&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;TRUNCATE removes the data by deallocating the data pages used to store the
  table’s data, and only the page deallocations are recorded in the transaction
  log.&lt;br /&gt;
Truncate is faster&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 3;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;DELETE does not reset Identity property of the table.&lt;br /&gt;
&lt;br /&gt;&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;TRUNCATE removes all the rows from a table, but the table structure, its
  columns, constraints, indexes and so on remains. &lt;br /&gt;
The counter used by an identity for new rows is reset to the seed for the
  column.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 4;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;Possible&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;&lt;span lang="EN"&gt;You cannot use TRUNCATE TABLE
  on a table referenced by a FOREIGN KEY constraint.&lt;/span&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 5;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;It can be rolled back.&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;&lt;span lang="EN"&gt;Using T-SQL – TRUNCATE cannot
  be rolled back unless it is used in TRANSACTION. OR TRUNCATE can be rolled
  back when used with BEGIN … END TRANSACTION using T-SQL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 6; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;&lt;span lang="EN"&gt;DELETE is DML Command.&lt;/span&gt;&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" width="295"&gt;&lt;span lang="EN"&gt;TRUNCATE is a DDL Command.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN" style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN" style="color: red;"&gt;4.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;u&gt;&lt;span lang="EN" style="color: red;"&gt;How is ACID property related to Database?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;u&gt;&lt;span lang="EN" style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in; text-align: justify;"&gt;
&lt;span lang="EN"&gt;ACID (an acronym for Atomicity Consistency Isolation Durability) is a
concept that Database Professionals generally look for while evaluating
databases and application architectures. For a reliable database, all this four
attributes should be achieved.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in; text-align: justify;"&gt;
&lt;strong&gt;&lt;span lang="EN"&gt;Atomicity:&lt;/span&gt;&lt;/strong&gt;&lt;span lang="EN"&gt; is an all-or-none proposition.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in; text-align: justify;"&gt;
&lt;strong&gt;&lt;span lang="EN"&gt;Consistency:&lt;/span&gt;&lt;/strong&gt;&lt;span lang="EN"&gt; guarantees that a transaction never leaves your
database in a half-finished state.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in; text-align: justify;"&gt;
&lt;strong&gt;&lt;span lang="EN"&gt;Isolation:&lt;/span&gt;&lt;/strong&gt;&lt;span lang="EN"&gt; keeps transactions separated from each other
until they are finished.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in; text-align: justify;"&gt;
&lt;strong&gt;&lt;span lang="EN"&gt;Durability:&lt;/span&gt;&lt;/strong&gt;&lt;span lang="EN"&gt; guarantees that the database will keep track of
pending changes in such a way that the server can recover from an abnormal
termination.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in; text-align: justify;"&gt;
&lt;span lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN" style="color: red;"&gt;5.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN" style="color: red;"&gt;What are the Different
Normalization Forms?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN" style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;b&gt;&lt;span lang="EN"&gt;1NF:
Eliminate Repeating Groups&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;Make a
separate table for each set of related attributes, and give each table a
primary key. Each field contains at most one value from its attribute domain.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;b&gt;&lt;span lang="EN"&gt;2NF:
Eliminate Redundant Data&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;If an
attribute depends on only part of a multi-valued key, then remove it to a
separate table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;b&gt;&lt;span lang="EN"&gt;3NF:
Eliminate Columns Not Dependent On Key&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;If
attributes do not contribute to a description of the key, then remove them to a
separate table. All attributes must be directly dependent on the primary key. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;b&gt;&lt;span lang="EN"&gt;BCNF:
Boyce-Codd &lt;st1:place w:st="on"&gt;Normal&lt;/st1:place&gt; Form&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;If there
are non-trivial dependencies between candidate key attributes, then separate
them out into distinct tables.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;b&gt;&lt;span lang="EN"&gt;4NF:
Isolate Independent Multiple Relationships&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;No table
may contain two or more 1:n or n:m relationships that are not directly related.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;b&gt;&lt;span lang="EN"&gt;5NF:
Isolate Semantically Related Multiple Relationships&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;There
may be practical constrains on information that justify separating logically
related many-to-many relationships.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;b&gt;&lt;span lang="EN"&gt;ONF:
Optimal &lt;st1:place w:st="on"&gt;Normal&lt;/st1:place&gt; Form&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;A model
limited to only simple (elemental) facts, as expressed in Object Role Model
notation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;b&gt;&lt;span lang="EN"&gt;DKNF:
Domain-Key &lt;st1:place w:st="on"&gt;Normal&lt;/st1:place&gt; Form&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;A model
free from all modification anomalies is said to be in DKNF.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;Remember,
these normalization guidelines are cumulative. For a database to be in 3NF, it
must first fulfill all the criteria of a 2NF and 1NF database.&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;span lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;6.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="color: red;"&gt;Triggers inside
Stored procedure &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
Got a query from users like, “Is it possible to use
trigger inside stored procedure. If not why? If yes how?”&lt;b style="mso-bidi-font-weight: normal;"&gt; &lt;/b&gt;&lt;br /&gt;
&lt;br style="mso-special-character: line-break;" /&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;My answer is
“No”&lt;/b&gt; &lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
We can’t use trigger inside stored procedure
because trigger is an object which is binded with table objects.&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l4 level1 lfo2; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/b&gt;The inherent property of the trigger is to fire
automatically if any condition breaks and it’s associated with DML operations.
But we are trying to create and initiate it from the stored procedure.&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l4 level1 lfo2; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/b&gt;It will loose its property as a System object.&lt;br /&gt;
&lt;br /&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;My answer is “Yes” &lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l3 level1 lfo3; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/b&gt;To provide an alternative way, Microsoft provides
us a new concept named CLR integration in sql server 2005.&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l3 level1 lfo3; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/b&gt;We can create Managed trigger and wrap it in the stored
procedure.&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l3 level1 lfo3; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;7.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;What is a View?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
If we have several tables in a db and we want to
view only specific columns from specific tables we can go for views. It would
also suffice the needs of security some times allowing specific users to see
only specific columns based on the permission that we can configure on the
view. Views also reduce the effort that is required for writing queries to
access specific columns every time.&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;span style="color: #3333ff;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span lang="EN" style="color: red;"&gt;8.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;What is an Index?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span lang="EN"&gt;An index is a physical structure
containing pointers to the data. Indices are created in an existing table to
locate rows more quickly and efficiently. It is possible to create an index on
one or more columns of a table, and each index is given a name. The users
cannot see the indexes; they are just used to speed up queries. Effective
indexes are one of the best ways to improve performance in a database
application. A table scan happens when there is no index available to help a
query. In a table scan, the SQL Server examines every row in the table to
satisfy the query results. Table scans are sometimes unavoidable, but on large
tables, scans have a terrific impact on performance.&lt;/span&gt;&lt;span lang="EN" style="color: red;"&gt; &lt;/span&gt;&lt;span lang="EN" style="font-size: 18pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;span lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span lang="EN" style="color: red;"&gt;9.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span lang="EN" style="color: red;"&gt;What is an Identity?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span lang="EN" style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in;"&gt;
&lt;span lang="EN"&gt;Identity (or AutoNumber) is a column that
automatically generates numeric values. A start and increment value can be set,
but most DBAs leave these at 1. A GUID column also generates unique keys. &lt;/span&gt;&lt;span lang="EN" style="font-size: 18pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in;"&gt;
&lt;span lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN" style="color: red;"&gt;10.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;What is a Linked
Server?&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in;"&gt;
&lt;span lang="EN"&gt;Linked
Servers is a concept in SQL Server by which we can add other SQL Server to a
Group and query both the SQL Server databases using T-SQL Statements. With a linked
server, you can create very clean, easy–to-follow SQL statements that allow
remote data to be retrieved, joined and combined with local data.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Stored Procedures sp_addlinkedserver,
sp_addlinkedsrvlogin will be used to add new Linked Server. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;11.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;What is a Cursor?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;A cursor is a database object used by
applications to manipulate data in a set on a row-by-row basis, instead of the
typical SQL commands that operate on all the rows in the set at one time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;In order to work with a cursor, we
need to perform some steps in the following order:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l1 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt; font-variant: normal !important; font-weight: normal;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Declare cursor &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l1 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt; font-variant: normal !important; font-weight: normal;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Open cursor &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l1 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt; font-variant: normal !important; font-weight: normal;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Fetch row from the cursor &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l1 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt; font-variant: normal !important; font-weight: normal;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Process
fetched row &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l1 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt; font-variant: normal !important; font-weight: normal;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Close cursor &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l1 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt; font-variant: normal !important; font-weight: normal;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Deallocate cursor &lt;/span&gt;&lt;span lang="EN" style="font-size: 18pt; font-variant: normal !important;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l1 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red; font-variant: normal !important;"&gt;12.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: red; font-variant: normal !important;"&gt;&lt;b&gt;What is Collation?&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span style="color: red; font-variant: normal !important;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Collation refers to a set of rules
that determine how data is sorted and compared. Character data is sorted using
rules that define the correct character sequence with options for specifying
case sensitivity, accent marks, Kana character types, and character width. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;13.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;Types of Indexes&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .75in; mso-list: l5 level1 lfo4; tab-stops: list .75in; text-indent: -.25in;"&gt;
&lt;span style="font-family: Symbol; font-size: 10pt;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Clustered Index &lt;/div&gt;
&lt;div style="margin-left: .75in; mso-list: l5 level1 lfo4; tab-stops: list .75in; text-indent: -.25in;"&gt;
&lt;span style="font-family: Symbol; font-size: 10pt;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Non-Clustered Index&lt;/div&gt;
&lt;div style="margin-left: .75in; mso-list: l5 level1 lfo4; tab-stops: list .75in; text-indent: -.25in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;14.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;Difference between Clustered Index and Non-Clustered Index.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-left: 0.5in; width: 590px;"&gt;
 &lt;tbody&gt;
&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" style="text-align: center;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;Clustered Index&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" style="text-align: center;"&gt;
&lt;b style="mso-bidi-font-weight: normal;"&gt;Non-Clustered Index&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 1;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;A clustered index is a special type of index that reorders the way in
  which records in the table are physically stored.&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;It won’t touch the structure of the table.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 2;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;Only one clustered index can be created for a table.&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;For a table, we can create 249 non clustered index.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 3;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;The leaf nodes of a clustered index contain the data pages.&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;The leaf node of a nonclustered index does not consist of the data pages.
  Instead, the leaf nodes contain index rows.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 4; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;By default, primary key will create clustered index on the table.&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;By default, Unique key will create clustered index on the table.&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;15.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="color: red;"&gt;Difference
between Stored Procedure and Trigger&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-left: 0.5in; width: 590px;"&gt;
 &lt;tbody&gt;
&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" style="text-align: center;"&gt;
&lt;b&gt;Stored Procedure&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" style="text-align: center;"&gt;
&lt;b&gt;Trigger&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 1;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Defination: &lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span lang="EN"&gt;A
  stored procedure is a collection of precompiled SQL statements that have been
  previously created and stored in the server database. &lt;/span&gt;&lt;b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Defination: &lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
It will
  fire automatically when ever DML operations performed on the table or view. &lt;span style="color: #3333ff;"&gt;Triggers are basically used to implement business
  rules.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 2;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div style="text-align: justify;"&gt;
Supports
  Input and Output parameters &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div style="text-align: justify;"&gt;
Not
  support&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 3;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div style="text-align: justify;"&gt;
&lt;span lang="EN"&gt;Stored
  procedures are explicitly executed by invoking a CALL to the procedure&lt;/span&gt;&lt;b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div style="text-align: justify;"&gt;
&lt;span lang="EN"&gt;Triggers
  are implicitly executed&lt;/span&gt;&lt;b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 4; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div style="text-align: justify;"&gt;
&lt;span lang="EN"&gt;Procedures
  can’t execute Triggers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div style="text-align: justify;"&gt;
&lt;span lang="EN"&gt;Triggers
  can execute stored procedures&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;16.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="color: red;"&gt;Difference
between Stored Proc and Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-left: 0.5in; width: 590px;"&gt;
 &lt;tbody&gt;
&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" class="MsoNormal" style="mso-layout-grid-align: none; text-align: center; text-autospace: none;"&gt;
&lt;span style="font-variant: normal !important;"&gt;Stored
  Proc&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" class="MsoNormal" style="mso-layout-grid-align: none; text-align: center; text-autospace: none;"&gt;
&lt;span style="font-variant: normal !important;"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 1;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-variant: normal !important; font-weight: normal;"&gt;Data manipulations
  are possible with in the procedure&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-variant: normal !important; font-weight: normal;"&gt;Not Possible&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 2;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-variant: normal !important; font-weight: normal;"&gt;Supports XML FOR
  clause&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-variant: normal !important; font-weight: normal;"&gt;Not supports&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 3;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;If there
  is an error in SP it just ignores the error and moves to the next statement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;If there
  is an error in UDF its stops executing.&lt;/span&gt;&lt;span style="font-variant: normal !important; font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 4;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;SP’s can
  make permanent changes to server environments&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;Can’t&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 5;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;Can’t&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;UDF can
  be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 6;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;Supports
  all data types&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Text, ntext, image and timestamp data types are not
  supported.&lt;/span&gt;&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 7; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important;"&gt;Defination: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;User-defined Functions allow defining its own T-SQL
  functions that can accept zero or more parameters and return a single scalar
  data value or a table data type.&lt;/span&gt;&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;17.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="color: red;"&gt;Difference between Primary key and Unique key?&lt;/span&gt;&lt;/b&gt;&lt;span style="color: red;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-left: 0.5in; width: 590px;"&gt;
 &lt;tbody&gt;
&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" style="text-align: center;"&gt;
&lt;b&gt;Primary key&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div align="center" style="text-align: center;"&gt;
&lt;b&gt;Unique key&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 1;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;It won’t allow null value&lt;o:p&gt;&lt;/o:p&gt;&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;It will accept null value but only
  one&lt;o:p&gt;&lt;/o:p&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 2;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;Only one primary key can be
  created for the table&lt;o:p&gt;&lt;/o:p&gt;&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;Any number of Unique key can be
  created for the table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 3;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;span lang="EN"&gt;Primary Key creates a clustered
  index on the column.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;span lang="EN"&gt;Unique Key creates a
  non-clustered index on the column.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 4; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;span lang="EN"&gt;Ex: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;em&gt;&lt;span lang="EN"&gt;Create table with Primary
  Key:&lt;/span&gt;&lt;/em&gt;&lt;span lang="EN"&gt;&lt;br /&gt;
  &lt;/span&gt;&lt;code&gt;&lt;span lang="EN" style="color: blue; font-size: 9pt;"&gt;CREATE TABLE &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: black; font-size: 9pt;"&gt;Authors &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: grey; font-size: 9pt;"&gt;(&lt;/span&gt;&lt;/code&gt;&lt;span lang="EN" style="color: grey; font-family: 'Courier New'; font-size: 9pt;"&gt;&lt;br /&gt;
  &lt;/span&gt;&lt;code&gt;&lt;span lang="EN" style="color: black; font-size: 9pt;"&gt;AuthorID &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: blue; font-size: 9pt;"&gt;INT &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: grey; font-size: 9pt;"&gt;NOT NULL &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: blue; font-size: 9pt;"&gt;PRIMARY KEY&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: grey; font-size: 9pt;"&gt;,&lt;/span&gt;&lt;/code&gt;&lt;span lang="EN" style="color: grey; font-family: 'Courier New'; font-size: 9pt;"&gt;&lt;br /&gt;
  &lt;/span&gt;&lt;code&gt;&lt;span lang="EN" style="color: black; font-size: 9pt;"&gt;Name &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: blue; font-size: 9pt;"&gt;VARCHAR&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: grey; font-size: 9pt;"&gt;(&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: black; font-size: 9pt;"&gt;100&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: grey; font-size: 9pt;"&gt;) NOT NULL&lt;/span&gt;&lt;/code&gt;&lt;span lang="EN" style="color: grey; font-family: 'Courier New'; font-size: 9pt;"&gt;&lt;br /&gt;
  &lt;code&gt;)&lt;/code&gt;&lt;/span&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;span lang="EN"&gt;Ex: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;em&gt;&lt;span lang="EN"&gt;Alter table to add unique
  constraint to column:&lt;/span&gt;&lt;/em&gt;&lt;span lang="EN"&gt;&lt;br /&gt;
  &lt;/span&gt;&lt;code&gt;&lt;span lang="EN" style="color: blue; font-size: 9pt;"&gt;ALTER TABLE &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: black; font-size: 9pt;"&gt;Authors &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: blue; font-size: 9pt;"&gt;ADD CONSTRAINT &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: black; font-size: 9pt;"&gt;IX_Authors_Name
  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: blue; font-size: 9pt;"&gt;UNIQUE&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: grey; font-size: 9pt;"&gt;(&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: black; font-size: 9pt;"&gt;Name&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span lang="EN" style="color: grey; font-size: 9pt;"&gt;)&lt;/span&gt;&lt;/code&gt;&lt;span lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;18.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="color: red;"&gt;Difference between Temp tables and Table variables in Sql
Server&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l1 level2 lfo5; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
1)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;Transaction
logs are not recorded for the table variables. They are variables and thus
aren't bound to a transaction.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .75in;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Temp tables behave same as normal tables
and are bound by transactions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l1 level2 lfo5; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
2)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;Any
procedure with a temporary table cannot be pre-compiled, while an execution
plan of procedures with table variables can be statically compiled in advance.
Pre-compiling a script gives a major advantage to its speed of execution. This
advantage can be dramatic for long procedures, where recompilation can be too
pricy.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l1 level2 lfo5; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
3)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;Table
variables exist only in the same scope as variables. Contrary to the temporary
tables, they are not visible in inner stored procedures and in exec (string)
statements. Also, they cannot be used in an insert/exec statement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l1 level2 lfo5; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
4)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;As a
rule of thumb, for small to medium volumes of data and simple usage scenarios
you should use table variables.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: 1.0in; mso-list: l1 level2 lfo5; tab-stops: list 1.0in; text-indent: -.25in;"&gt;
5)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;If we
use Temporary Table in a stored procedure, we should drop it at the end. It is
not necessary in the case of Table variable.&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="margin-left: .25in;"&gt;
&lt;b&gt;A simple example shows this difference quite
nicely:&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
BEGIN TRAN&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
declare
@var table (id int, data varchar(20) )&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
create
table #temp (id int, data varchar(20) )&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
insert into
@var&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select 1,
'data 1' union all&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select 2,
'data 2' union all&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select 3,
'data 3'&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
insert into
#temp&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select 1,
'data 1' union all&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select 2,
'data 2' union all&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select 3,
'data 3'&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select *
from #temp&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select *
from @var&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
ROLLBACK&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select *
from @var&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
if
object_id('tempdb..#temp') is null&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .5in;"&gt;
select
'#temp does not exist outside the transaction'&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in;"&gt;
We see
that the table variable still exists and has all it's data unlike the temporary
table that doesn't exists when the transaction rollbacked.&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: .25in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;19.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;What are Different Types of Join?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 12.0pt; mso-outline-level: 4; text-align: justify;"&gt;
&lt;span lang="EN" style="color: #384f83; font-variant: normal !important;"&gt;Cross Join: &lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;A cross join that
does not have a WHERE clause produces the Cartesian product of the tables
involved in the join. The size of a Cartesian product result set is the number
of rows in the first table multiplied by the number of rows in the second
table. The common example is when company wants to combine each product with a
pricing table to analyze each product at each price.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="color: #384f83; font-variant: normal !important;"&gt;Inner Join:&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;
A join that displays only the rows that have a match in both joined tables is
known as inner Join. This is the default type of join in the Query and View
Designer.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 12.0pt; mso-outline-level: 4; text-align: justify;"&gt;
&lt;span lang="EN" style="color: #384f83; font-variant: normal !important;"&gt;Outer Join:&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt; A join that includes rows even if
they do not have related rows in the joined table is an Outer Join. You can
create three different outer join to specify the unmatched rows to be included:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l0 level1 lfo6; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt; font-variant: normal !important; font-weight: normal;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="color: #384f83; font-variant: normal !important;"&gt;Left Outer Join:&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;
In Left Outer Join, all the rows in the first-named table, i.e. “left” table,
which appears leftmost in the JOIN clause, are included. Unmatched rows in the
right table do not appear.&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l6 level1 lfo7; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt; font-variant: normal !important; font-weight: normal;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="color: #384f83; font-variant: normal !important;"&gt;Right Outer Join:&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;
In Right Outer Join, all the rows in the second-named table, i.e. “right”
table, which appears rightmost in the JOIN clause are included. Unmatched rows
in the left table are not included. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .75in; mso-list: l7 level1 lfo8; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .75in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="font-family: Symbol; font-size: 10pt; font-variant: normal !important; font-weight: normal;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="color: #384f83; font-variant: normal !important;"&gt;Full Outer Join:&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;
In Full Outer Join, all the rows in all joined tables are included, whether
they are matched or not. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 12.0pt; mso-outline-level: 4; text-align: justify;"&gt;
&lt;span lang="EN" style="color: #384f83; font-variant: normal !important;"&gt;Self Join: &lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;This is a particular case when one
table joins to itself with one or two aliases to avoid confusion. A self join
can be of any type, as long as the joined tables are the same. A self join is
rather unique in that it involves a relationship with only one table. The
common example is when company has a hierarchal reporting structure whereby one
member of staff reports to another. Self Join can be Outer Join or Inner Join. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;20.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;What are Primary Keys and Foreign Keys?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Primary keys are the unique
identifiers for each row. They must contain unique values and cannot be null.
Due to their importance in relational databases, Primary keys are the most
fundamental aspect of all keys and constraints. A table can have only one
primary key.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Foreign keys are a method of ensuring
data integrity and manifestation of the relationship between tables.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span style="color: red; font-family: TimesNewRomanPSMT; font-variant: normal !important;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span style="color: red; font-family: TimesNewRomanPSMT; font-variant: normal !important;"&gt;21.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: red; font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important;"&gt;What is a
candidate key? &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2; text-align: justify;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;A table
may have more than one combination of columns that could uniquely identify the
rows in a table; each combination is a candidate key. During database design
you can pick up one of the candidate keys to be the primary key. For example,
in the supplier table supplierid and suppliername can be candidate key but you
will only pick up supplierid as the primary key.&lt;/span&gt;&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2; text-align: justify;"&gt;
&lt;span style="font-family: TimesNewRomanPSMT; font-size: 11pt; font-variant: normal !important; font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2; tab-stops: list .25in; text-align: justify; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;22.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;What is User-defined Functions? What are the types
of User-defined Functions that can be created?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;User-defined Functions allow defining
its own T-SQL functions that can accept zero or more parameters and return a
single scalar data value or a table data type.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;i&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Different Types of
User-Defined Functions created are as follows: &lt;/span&gt;&lt;/i&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;i&gt;&lt;span lang="EN" style="font-variant: normal !important;"&gt;Scalar
User-defined Function:&lt;/span&gt;&lt;/i&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;A scalar user-defined function returns
one of the scalar data types. Text, ntext, image and timestamp data types are
not supported. These are the type of user-defined functions that most developers
are used to in other programming languages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;i&gt;&lt;span lang="EN" style="font-variant: normal !important;"&gt;Inline
Table-Value User-defined Function:&lt;/span&gt;&lt;/i&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;An Inline table-value user-defined
function returns a table data type and is an exceptional alternative to a view
as the user-defined function can pass parameters into a T-SQL select command
and in essence provide us with a parameterized, non-updateable view of the
underlying tables.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;i&gt;&lt;span lang="EN" style="font-variant: normal !important;"&gt;Multi-Statement
Table-Value User-defined Function:&lt;/span&gt;&lt;/i&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;A multi-statement table-value
user-defined function returns a table, and it is also an exceptional
alternative to a view as the function can support multiple T-SQL statements to
build the final result where the view is limited to a single SELECT statement.
Also, the ability to pass parameters into a T-SQL select command or a group of
them gives us the capability to in essence create a parameterized,
non-updateable view of the data in the underlying tables. Within the create
function command, you must define the table structure that is being returned.
After creating this type of user-defined function, It can be used in the FROM
clause of a T-SQL command unlike the behavior encountered while using a stored
procedure which can also return record sets. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;23.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="color: red;"&gt;What
is Dirty Read?&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;A dirty read occurs
when two operations, say, read and write occur together giving the incorrect or
unedited data. Suppose, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in;"&gt;
&lt;span lang="EN" style="font-variant: normal !important;"&gt;A&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt; changed a row but
did not committed the changes. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in;"&gt;
&lt;span lang="EN" style="font-variant: normal !important;"&gt;B&lt;/span&gt;&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt; reads the
uncommitted data but his view of the data may be wrong so that is Dirty Read.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;24.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;Why
can’t I use Outer Join in an Indexed View?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;Rows can logically
disappear from an indexed view based on OUTER JOIN when you insert data into a
base table. This makes incrementally updating OUTER JOIN views relatively
complex to implement, and the performance of the implementation would be slower
than for views based on standard (INNER) JOIN.&lt;/span&gt;&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;25.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="color: red; font-variant: normal !important;"&gt;What is the Correct Order of the Logical Query
Processing Phases?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;The correct order of
the Logical Query Processing Phases is as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;
&lt;span lang="EN" style="font-variant: normal !important; font-weight: normal;"&gt;1. FROM&lt;br /&gt;
2. ON&lt;br /&gt;
3. OUTER&lt;br /&gt;
4. WHERE&lt;br /&gt;
5. GROUP BY&lt;br /&gt;
6. With {CUBE | ROLLUP}&lt;br /&gt;
7. HAVING&lt;br /&gt;
8. SELECT&lt;br /&gt;
9. DISTINCT&lt;br /&gt;
10. TOP&lt;br /&gt;
11. ORDER BY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-list: l2 level1 lfo1; tab-stops: list .25in; text-indent: -.25in;"&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .25in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="margin-left: .25in; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-7820785627303714113?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4veBPFNID3WOkclZ8o1rETZtbEE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4veBPFNID3WOkclZ8o1rETZtbEE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4veBPFNID3WOkclZ8o1rETZtbEE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4veBPFNID3WOkclZ8o1rETZtbEE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/KA9g_15gKzE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/7820785627303714113/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=7820785627303714113" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/7820785627303714113?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/7820785627303714113?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/KA9g_15gKzE/best-sql-server-interview-questions.html" title="Best Sql Server Interview Questions 2000/2005/2008 : Part 1" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/10/best-sql-server-interview-questions.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUQFQH4-cCp7ImA9WhdUEE4.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-8972379207113343039</id><published>2011-09-26T17:06:00.000+05:30</published><updated>2011-09-26T17:11:51.058+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-26T17:11:51.058+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Send Mail with multiple attachments in asp.net</title><content type="html">&lt;u&gt;&lt;b&gt;Use below code to Send multiple attachments in Email&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;.ASPX&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="SendMail.aspx.cs" Inherits="SendMail" %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table cellspacing="0" cellpadding="3" width="100%" bgcolor="navy" border="0"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td align="center"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="titl"&amp;gt;ASP.NET&amp;amp;nbsp;Email&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div align="center"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label ID="lblMessage" runat="server" Font-Names="Arial" Width="540" Visible="False"&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div align="center"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form id="Form1" name="form2" method="post" enctype="multipart/form-data" runat="server"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table cellspacing="0" cellpadding="4" bgcolor="navy" border="0"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table cellspacing="3" cellpadding="4" width="540" bgcolor="white"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td valign="middle" align="right" width="80"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox ID="txtSender" TabIndex="1" runat="server" MaxLength="100" Width="386px"&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CssClass="width386" Font-Names="Arial"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td valign="middle" align="right" width="80"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; To:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox ID="txtReceiver" TabIndex="1" runat="server" MaxLength="100" Width="386px"&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CssClass="width386" Font-Names="Arial"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td valign="middle" align="right"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Subject:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox ID="txtSubject" TabIndex="2" runat="server" MaxLength="200" Width="386px"&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CssClass="width386" Font-Names="Arial"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td valign="middle" align="right"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Format:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:RadioButtonList ID="rblMailFormat" TabIndex="3" runat="server" RepeatColumns="2"&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RepeatDirection="Horizontal"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:ListItem Value="text" Selected="True"&amp;gt;text&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:ListItem Value="html"&amp;gt;html&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:RadioButtonList&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td valign="top" align="right"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Message:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td height="84"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;p&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox ID="txtBody" TabIndex="4" runat="server" Columns="40" Rows="5" TextMode="MultiLine"&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Width="451px" CssClass="width386" Font-Names="Arial"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:FileUpload ID="FileUpload1" runat="server" style="margin-left: 0px" &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Width="445px" /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td align="center" colspan="2"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Button ID="btnSend" TabIndex="9" runat="server" Width="100px" Text="Send" OnClick="btnSend_Click"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:Button&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;h1&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;u&gt;&lt;b&gt;.ASPX.CS&lt;/b&gt;&lt;/u&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Net.Mail;&lt;br /&gt;
&lt;br /&gt;
public partial class SendMail : System.Web.UI.Page&lt;br /&gt;
{&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void btnSend_Click(object sender, EventArgs e)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create a new blank MailMessage&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MailMessage email = new MailMessage();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set the properties of the MailMessage to the values on the form&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (rblMailFormat.SelectedItem.Text == "text")&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.IsBodyHtml = false;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.IsBodyHtml = true;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.From = new MailAddress(txtSender.Text);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.To.Add(new MailAddress(txtReceiver.Text));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.Subject = txtSubject.Text;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.Body = txtBody.Text;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string strFileName = FileUpload1.PostedFile.FileName;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //adding attachements from browse &amp;amp; upload&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Attachment attach = new Attachment(strFileName);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Follow the same trick for multiple attachment&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.Attachments.Add(attach);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Set the SMTP server &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SmtpClient smtp = new SmtpClient("localhost");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // send the email&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtp.Send(email);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Reset the form&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtSender.Text = "";&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtReceiver.Text = "";&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtSubject.Text = "";&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtBody.Text = "";&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Dispaly a friendly message telling the user&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // his email has been sent&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblMessage.Visible = true;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblMessage.ForeColor = Color.Black;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblMessage.Text = "Your email has been sent";&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (Exception ex)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblMessage.Visible = true;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblMessage.ForeColor = Color.Red;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblMessage.Text = ex.ToString();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-8972379207113343039?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XIScuVSoAg2MXsZJ-BzayXb8x1U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XIScuVSoAg2MXsZJ-BzayXb8x1U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XIScuVSoAg2MXsZJ-BzayXb8x1U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XIScuVSoAg2MXsZJ-BzayXb8x1U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/0P5U94kpTq4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/8972379207113343039/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=8972379207113343039" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/8972379207113343039?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/8972379207113343039?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/0P5U94kpTq4/send-mail-with-multiple-attachments-in.html" title="Send Mail with multiple attachments in asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/send-mail-with-multiple-attachments-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8HQXs_cSp7ImA9WhdUEE4.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-2734623050380023707</id><published>2011-09-26T13:12:00.000+05:30</published><updated>2011-09-26T17:20:30.549+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-26T17:20:30.549+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>How do I change the SMTP port number dynamically in asp.net</title><content type="html">&lt;u&gt;&lt;i&gt;&lt;b&gt;Use below method to set dynamic port while sending the email using SMTP&lt;/b&gt;&lt;/i&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
public static void SendMailwithDynamicPort(string strSmtpHost, int strPort, string strMessageBody, string strFrom, string strTo, string strSubject)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create and configure the smtp client&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SmtpClient smtpClient = new SmtpClient();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (strSmtpHost != null &amp;amp;&amp;amp; strSmtpHost.Length &amp;gt; 0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpClient.Host = strSmtpHost;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b style="background-color: #8e7cc3;"&gt; smtpClient.Port = strPort; // you can read from config&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MailMessage mailMessage = new MailMessage();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mailMessage.Body = strMessageBody;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mailMessage.From = new MailAddress(strFrom);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mailMessage.To.Add(strTo);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mailMessage.Subject = strSubject;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mailMessage.Priority = MailPriority.Normal;//to set the email property&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpClient.Send(mailMessage);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;i&gt;&lt;b&gt;or through Web.Config also we can set port number&lt;/b&gt;&lt;/i&gt;&lt;/u&gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;pre&gt;&lt;span style="background-color: #f6b26b;"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #f6b26b;"&gt;  &amp;lt;!-- Add the email settings to the &amp;lt;system.net&amp;gt; element --&amp;gt;&lt;/span&gt;
&lt;b style="background-color: #f6b26b;"&gt;  &amp;lt;system.net&amp;gt;
    &amp;lt;mailSettings&amp;gt;
      &amp;lt;smtp&amp;gt;
        &amp;lt;network 
             host="&lt;i&gt;relayServerHostname&lt;/i&gt;" 
             port="&lt;i&gt;portNumber&lt;/i&gt;"
             userName="&lt;i&gt;username&lt;/i&gt;"
             password="&lt;i&gt;password&lt;/i&gt;" /&amp;gt;
      &amp;lt;/smtp&amp;gt;
    &amp;lt;/mailSettings&amp;gt;
  &amp;lt;/system.net&amp;gt;&lt;/b&gt;

&lt;span style="background-color: #f6b26b;"&gt;  &amp;lt;system.web&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #f6b26b;"&gt;    ...&lt;/span&gt;
&lt;span style="background-color: #f6b26b;"&gt;  &amp;lt;/system.web&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #f6b26b;"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-2734623050380023707?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/x5b1QOPh0dObMN3wYW5S7FtLkx4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/x5b1QOPh0dObMN3wYW5S7FtLkx4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/x5b1QOPh0dObMN3wYW5S7FtLkx4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/x5b1QOPh0dObMN3wYW5S7FtLkx4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/3nHEEx4-m48" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/2734623050380023707/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=2734623050380023707" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/2734623050380023707?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/2734623050380023707?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/3nHEEx4-m48/how-do-i-change-smtp-port-number.html" title="How do I change the SMTP port number dynamically in asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/how-do-i-change-smtp-port-number.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQGQHw5cSp7ImA9WhdUEE8.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-4937587574920392631</id><published>2011-09-26T12:28:00.001+05:30</published><updated>2011-09-26T12:28:41.229+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-26T12:28:41.229+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>How to get the users IP those who are accessing your website using asp.net</title><content type="html">&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Use below code to get the IP of your website users:&lt;/b&gt;&lt;/u&gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;%@ Page Language="C#" %&amp;gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;Client IP...&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;meta http-equiv="Expires" content="-1"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;meta http-equiv="Cache-Control" content="no-cache"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;meta http-equiv="Pragma" content="no-cache"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;%&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string _strClientIP = string.Empty;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string[] _strforwardedIpsList;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get exact IP address if proxy available&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string _strServerVariable = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!string.IsNullOrEmpty(_strServerVariable))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _strforwardedIpsList = _strServerVariable.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _strClientIP = _strforwardedIpsList[_strforwardedIpsList.Length - 1];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get Proxy IP address&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _strClientIP = HttpContext.Current.Request.UserHostAddress;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (string.IsNullOrEmpty(_strClientIP))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _strClientIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Write(_strClientIP);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;%&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form id="testForm"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-4937587574920392631?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/WRJlrrwa5ZeYJx75TSaHYp4aMyE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WRJlrrwa5ZeYJx75TSaHYp4aMyE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/WRJlrrwa5ZeYJx75TSaHYp4aMyE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WRJlrrwa5ZeYJx75TSaHYp4aMyE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/ilmr_2f9xbA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/4937587574920392631/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=4937587574920392631" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/4937587574920392631?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/4937587574920392631?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/ilmr_2f9xbA/how-to-get-users-ip-those-who-are.html" title="How to get the users IP those who are accessing your website using asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/how-to-get-users-ip-those-who-are.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQAQn4_eyp7ImA9WhdUEE8.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-1498160092695918632</id><published>2011-09-23T15:12:00.000+05:30</published><updated>2011-09-26T12:29:03.043+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-26T12:29:03.043+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="IIS" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>"Cannot get IIS pickup directory" SMTP exception in asp.net</title><content type="html">Use below code to resolve the issue&lt;br /&gt;
&lt;br /&gt;
&lt;div style="background-color: #d5a6bd;"&gt;
&lt;b&gt;smtp.DeliveryMethod = SmtpDeliveryMethod.NetWork&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
instead of &lt;br /&gt;

&lt;br /&gt;
&lt;div style="background-color: #d5a6bd;"&gt;
smtp.DeliverMethod=smtpDeliverMethod.pickUpis....&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-1498160092695918632?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/l5xM7PQxtWuJIHG0G9nJYcuIzug/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/l5xM7PQxtWuJIHG0G9nJYcuIzug/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/l5xM7PQxtWuJIHG0G9nJYcuIzug/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/l5xM7PQxtWuJIHG0G9nJYcuIzug/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/b9MTj21_5j0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/1498160092695918632/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=1498160092695918632" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/1498160092695918632?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/1498160092695918632?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/b9MTj21_5j0/cannot-get-iis-pickup-directory-smtp.html" title="&quot;Cannot get IIS pickup directory&quot; SMTP exception in asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/cannot-get-iis-pickup-directory-smtp.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MHR30_fSp7ImA9WhdVFUU.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-3132757318462723768</id><published>2011-09-21T11:40:00.000+05:30</published><updated>2011-09-21T11:40:36.345+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-21T11:40:36.345+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WCF" /><title>Host WCF service with multiple host environment using multiple protocol</title><content type="html">&lt;h2&gt;

Introduction&lt;/h2&gt;
In the world of distributed application, many technologies has been introduced, implemented and used like DCOM, CORBA,…etc.&lt;br /&gt;
And after that, a new concept has been adapted,it was&amp;nbsp;the web 
services. Web service is simple to develop and implement without paying 
attention to firewall issues and as a result, communication between 
systems has been simplified.&lt;br /&gt;
The problem while developing a web service is you need to host it 
inside a web server like IIS or Apache using http or wshttp protocols, 
and this is the only option you have. &lt;br /&gt;
WCF has solved this issue, by 
providing the possibility to host your service in a different 
application process using also various protocols.&lt;br /&gt;
In this article I’ll show how you can achieve this.&lt;br /&gt;
The sample code includes a simple WCF service, console windows host, 
windows service host, IIS6 host, II7 host and client console windows 
application built in VS 2008 Standard edition and .NET 3.0.&lt;br /&gt;
&lt;h2&gt;

Background&lt;/h2&gt;
As we know if you adopt web services architecture for your system, you need the flowing:&lt;br /&gt;
- create a service like a component library using [WebService] and [WebMethod] attributes&lt;br /&gt;
- host it inside a web server like IIS&lt;br /&gt;
- generate a proxy (interface or contract) from the WSDL&lt;br /&gt;
- distribute this proxy to clients application who needs to call and use this web service. &lt;br /&gt;
&lt;h2&gt;

Multiple Host and Protocol Support with WCF&lt;/h2&gt;
Microsoft has introduced the WCF concept in order to make distributed application development and deployment simple.&lt;br /&gt;
&lt;br /&gt;
&lt;table border="1" cellpadding="1" cellspacing="1" style="width: 100%;"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="width: 50%;"&gt;&lt;b&gt;Hosting Environment&lt;/b&gt;&lt;/td&gt;

&lt;td style="width: 50%;"&gt;&lt;b&gt;Supported protocol&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="width: 50%;"&gt;Windows console and form application&lt;/td&gt;

&lt;td style="width: 50%;"&gt;HTTP,net.tcp,net.pipe,net.msmq&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="width: 50%;"&gt;Windows service application (formerly known as NT services)&lt;/td&gt;

&lt;td style="width: 50%;"&gt;HTTP,net.tcp,net.pipe,net.msmq&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="width: 50%;"&gt;Web server IIS6&lt;/td&gt;

&lt;td style="width: 50%;"&gt;http, wshttp&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="width: 50%;"&gt;Web server IIS7 - Windows Process Activation Service (WAS)&lt;/td&gt;

&lt;td style="width: 50%;"&gt;http, wshttp, net.tcp, net.pipe, net.msmq&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;img alt="Architect_Article.PNG" height="482" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/Architect_Article.PNG" width="605" /&gt;&lt;br /&gt;
&lt;h2&gt;

Create a test service&lt;/h2&gt;
Here I have created a very simple service called “FirstWcfService.Service” as in the following listing -1 :&lt;br /&gt;
&lt;img alt="FirstWcfService.PNG" height="176" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/FirstWcfService.PNG" width="215" /&gt;&lt;br /&gt;
&lt;pre lang="cs"&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Listing -1 IService.cs file&lt;/span&gt;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.Runtime.Serialization;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.ServiceModel;
&lt;span class="code-keyword"&gt;namespace&lt;/span&gt; FirstWcfService
{
    [ServiceContract]
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;interface&lt;/span&gt; IService
    {
   
        [OperationContract]
        &lt;span class="code-keyword"&gt;string&lt;/span&gt; Hello(); 
    }
}
&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Service.cs file&lt;/span&gt;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System;
&lt;span class="code-keyword"&gt;namespace&lt;/span&gt; FirstWcfService
{
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; Service : IService
    {
        &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; Hello()
        {
            &lt;span class="code-keyword"&gt;return&lt;/span&gt; (&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Hello WCF"&lt;/span&gt;);
        }
    }
}&lt;/pre&gt;
As we can see, this service contains only on operation contract (Hello), this operation will return simple string “Hello WCF”.&lt;br /&gt;
&lt;h2&gt;

&lt;br /&gt;Hosting our service&lt;/h2&gt;
As I have mentioned in the begging of my article, with the arrival of WCF, now we have multiple options to host this service.&lt;br /&gt;
In each hosting environment, we need to provide an endpoint for this 
service and also we need to reference it, in order the client 
application can reach this service.&lt;br /&gt;
What does that mean practically, it means we have to create a configuration file for our hosted service. &lt;br /&gt;
&lt;h2&gt;

Option 1 – windows console host application&lt;/h2&gt;
1 - I created here a classic console application (picture 1) and then I hosted my service as in the following listing – 2:&lt;br /&gt;
&lt;img alt="FirstWcfServiceHostConsoleApp.PNG" height="162" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/FirstWcfServiceHostConsoleApp.PNG" width="200" /&gt;&lt;br /&gt;
&lt;pre lang="cs"&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Listing – 2 Program.cs&lt;/span&gt;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.Text;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.ServiceModel;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.ServiceModel.Description;
&lt;span class="code-keyword"&gt;namespace&lt;/span&gt; FirstWcfServiceHostConsoleApp
{
    &lt;span class="code-keyword"&gt;class&lt;/span&gt; Program
    {
        &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; Main(&lt;span class="code-keyword"&gt;string&lt;/span&gt;[] args)
        {
          
&lt;span class="code-keyword"&gt;using&lt;/span&gt; (ServiceHost host = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ServiceHost(&lt;span class="code-keyword"&gt;typeof&lt;/span&gt;(FirstWcfService.Service)))
            {
                host.Open();
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Press &amp;lt;Enter&amp;gt; to terminate the Host application."&lt;/span&gt;);
                Console.ReadLine();
            }
           
        }
    }
}&lt;/pre&gt;
&lt;pre lang="cs"&gt;&amp;nbsp;&lt;/pre&gt;
In order to host a WCF service inside a console application we need a
 minimum of work. Let us examine the code in the above listing:&lt;br /&gt;
This code &lt;i&gt;ServiceHost host = new ServiceHost(typeof(FirstWcfService.Service) &lt;/i&gt;&lt;br /&gt;
creates an instane of our service.&lt;br /&gt;
This line &lt;i&gt;host.Open() &lt;/i&gt;makes the service ready for access inside the hosting enviroemnt.&lt;br /&gt;
2- Secondly I have created a configuration file with a minimum configuration options as in the following listing - 3:&lt;br /&gt;
&lt;br /&gt;
&lt;pre lang="xml"&gt;//Listing – 3 App.config
&lt;span class="code-SummaryComment" style="background-color: #6fa8dc;"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #6fa8dc;"&gt;xml&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #6fa8dc;"&gt;version&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;1.0"&lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #6fa8dc;"&gt;?&lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;configuration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;  &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;system.serviceModel&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;services&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;service&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;name&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;FirstWcfService.Service"&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;ServiceBehavior"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;        &lt;/span&gt;&lt;span class="code-comment" style="background-color: #6fa8dc;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&lt;span class="code-comment"&gt; Service Endpoints &lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;endpoint&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;address&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;FirstWcfService"&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;binding&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;netTcpBinding"&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;            &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;contract&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;FirstWcfService.IService"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;        &lt;/span&gt;&lt;span class="code-comment" style="background-color: #6fa8dc;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&lt;span class="code-comment"&gt; This Endpoint is used for genertaing the proxy for the client &lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-comment" style="background-color: #6fa8dc;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&lt;span class="code-comment"&gt; To avoid disclosing metadata information, set the value below to false and
       remove the metadata endpoint above before deployment &lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;endpoint&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;address&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;mex"&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;contract&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;IMetadataExchange"&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;binding&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;mexTcpBinding"&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;host&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;          &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;baseAddresses&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;            &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;add&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;baseAddress&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;net.tcp://localhost:9100/"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;          &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;baseAddresses&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;host&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;service&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;services&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;behaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;serviceBehaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;behavior&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;name&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;ServiceBehavior"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;          &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;serviceMetadata&lt;/span&gt;&lt;span style="background-color: #6fa8dc;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #6fa8dc;"&gt;httpGetEnabled&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;false"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;behavior&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;serviceBehaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;behaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #6fa8dc;"&gt;  &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;system.serviceModel&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #6fa8dc;"&gt;configuration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #6fa8dc;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;h2&gt;

Option 2 – windows service host application&lt;/h2&gt;
1 - I created here a classic windows service application and then I hosted my service as in the following listing – 4:&lt;br /&gt;
&lt;img alt="FirstWcfServiceWindowsServiceHost.PNG" height="210" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/FirstWcfServiceWindowsServiceHost.PNG" width="206" /&gt;&lt;br /&gt;
&lt;pre lang="cs"&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Listing - 4, Program.cs&lt;/span&gt;&lt;/pre&gt;
&lt;pre lang="cs"&gt;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.ServiceProcess;
&lt;span class="code-keyword"&gt;namespace&lt;/span&gt; Windows_Service
{
    &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; Program
    {
        &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; Main()
        {
            ServiceBase[] ServicesToRun;
            ServicesToRun = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ServiceBase[] { &lt;span class="code-keyword"&gt;new&lt;/span&gt; WCFWindowsService() };
            ServiceBase.Run(ServicesToRun);
        }
    }
}&lt;/pre&gt;
&lt;pre lang="cs"&gt;
&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Listing - 4, WCFWindowsService.cs&lt;/span&gt;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.ComponentModel;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.Diagnostics;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.ServiceProcess;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.ServiceModel;
&lt;span class="code-keyword"&gt;namespace&lt;/span&gt; Windows_Service
{
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;partial&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; WCFWindowsService : ServiceBase
    {
       ServiceHost m_serviceHost;
        
&lt;span class="code-keyword"&gt;protected&lt;/span&gt; &lt;span class="code-keyword"&gt;override&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; OnStart(&lt;span class="code-keyword"&gt;string&lt;/span&gt;[] args)
        {
            m_serviceHost = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ServiceHost(&lt;span class="code-keyword"&gt;typeof&lt;/span&gt;(FirstWcfService.Service));
            m_serviceHost.Open();
        }
        
        &lt;span class="code-keyword"&gt;protected&lt;/span&gt; &lt;span class="code-keyword"&gt;override&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; OnStop()
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (m_serviceHost != &lt;span class="code-keyword"&gt;null&lt;/span&gt;)
            {
                m_serviceHost.Close();
            }
            m_serviceHost = &lt;span class="code-keyword"&gt;null&lt;/span&gt;;
        }
    }
}&lt;/pre&gt;
&lt;pre lang="cs"&gt;&amp;nbsp;&lt;/pre&gt;
In order to host a WCF service inside a windows service application, 
we need also a minimum of work by implementing the followings functions:&lt;br /&gt;
void OnStart(string[] args) and protected override void OnStop()&lt;br /&gt;
Let us examine the code in the above listing:&lt;br /&gt;
This code:&lt;br /&gt;
&lt;br /&gt;
m_serviceHost = new ServiceHost(typeof(FirstWcfService.Service));&lt;br /&gt;
m_serviceHost.Open();&lt;br /&gt;
&lt;br /&gt;
creates an instane of our service and then makes the service ready for access inside the hosting enviroment.&lt;br /&gt;
2 - To make this application working like a windows service, we 
should install it as in Listing – 5. This file is not related to WCF 
implementation, so I’m not going to explain what does this code does.&lt;br /&gt;
&lt;br /&gt;
&lt;pre lang="cs"&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Listing - 5, WCFWindowsServiceInstaller.cs&lt;/span&gt;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.Collections;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.ComponentModel;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.Configuration.Install;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System.ServiceProcess;
&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; To install or uninstall this Windows service via cmd:&lt;/span&gt;
&lt;span class="code-comment"&gt;//&lt;/span&gt;
&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;C:\Program Files\Microsoft Visual Studio 9.0\VC&amp;gt;installutil.exe /u  yourpath/WCFWindowsService.exe&lt;/span&gt;
&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;C:\Program Files\Microsoft Visual Studio 9.0\VC&amp;gt;installutil.exe     yourpath/WCFWindowsService.exe&lt;/span&gt;
&lt;span class="code-keyword"&gt;namespace&lt;/span&gt; Windows_Service
{
    [RunInstaller(&lt;span class="code-keyword"&gt;true&lt;/span&gt;)]
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;partial&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; WCFWindowsServiceInstaller : Installer
    {
        &lt;span class="code-keyword"&gt;public&lt;/span&gt; WCFWindowsServiceInstaller()
        {
            InitializeComponent();
            ServiceProcessInstaller processInstaller = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ServiceProcessInstaller();
            ServiceInstaller serviceInstaller = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ServiceInstaller();
            processInstaller.Account = ServiceAccount.LocalSystem;
            serviceInstaller.DisplayName = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WCF_WindowsService"&lt;/span&gt;;
            serviceInstaller.Description = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WCF_WindowsService."&lt;/span&gt;;
            serviceInstaller.ServiceName = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WCF_WindowsService"&lt;/span&gt;;
            serviceInstaller.StartType = ServiceStartMode.Manual;
            Installers.Add(processInstaller);
            Installers.Add(serviceInstaller);
        }
    }
}&lt;/pre&gt;
3 - I have created a configuration file with a minimum configuration options as in the following listing - 6:&lt;br /&gt;
&lt;pre&gt; &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Listing - 6, App.config&lt;/span&gt;
&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;?xml version=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;1.0"&lt;/span&gt; encoding=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;utf-8"&lt;/span&gt; ?&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;configuration&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;system.serviceModel&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;services&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;service name=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;FirstWcfService.Service"&lt;/span&gt; behaviorConfiguration=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;ServiceBehavior"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;endpoint address=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;FirstWcfService"&lt;/span&gt; contract=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;FirstWcfService.IService"&lt;/span&gt;
             binding=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;netTcpBinding"&lt;/span&gt; /&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;!-- This Endpoint is used &lt;span class="code-keyword"&gt;for&lt;/span&gt; genertaing the proxy &lt;span class="code-keyword"&gt;for&lt;/span&gt; the client --&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;endpoint address=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;mex"&lt;/span&gt; contract=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;IMetadataExchange"&lt;/span&gt; binding=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;mexTcpBinding"&lt;/span&gt; /&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;host&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;baseAddresses&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;add baseAddress=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;net.tcp://localhost:9000"&lt;/span&gt;/&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/baseAddresses&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/host&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/service&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/services&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;behaviors&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;serviceBehaviors&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;behavior name=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;ServiceBehavior"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;serviceMetadata httpGetEnabled=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;false"&lt;/span&gt;/&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/behavior&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/serviceBehaviors&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/behaviors&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/system.serviceModel&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/configuration&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;h2&gt;

Option 3 – IIS6 host application&lt;/h2&gt;
1 - I created here a simple WCF Service web application and then I 
have referenced FirstWcfService in order to host it as in the following 
listing – 7:&lt;br /&gt;
&lt;img alt="FirstWcfIIS6Host.PNG" height="134" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/FirstWcfIIS6Host.PNG" width="190" /&gt;&lt;br /&gt;
&lt;pre lang="cs"&gt; &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Listing - 7, file Service.svc&lt;/span&gt;
&lt;span class="code-pagedirective"&gt;&amp;lt;%@&lt;/span&gt;&lt;span class="code-leadattribute"&gt; ServiceHost Language&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;C#"&lt;/span&gt;&lt;span class="code-attribute"&gt; Debug&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;true"&lt;/span&gt;&lt;span class="code-attribute"&gt; Service&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;FirstWcfService.Service"&lt;/span&gt;&lt;span class="code-pagedirective"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
As see can see her, when we host a WCF service inside IIS, we do not 
need to create a host service and open it as we have done in the console
 and service windows application hosting, because IIS is responsible for
 creating the service and make it listening to clients calls, all we 
need just the above code inside a .svc file.&lt;br /&gt;
2- I have created a configuration file with a minimum configuration options as in the following listing -8:&lt;br /&gt;
&lt;pre lang="xml"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre lang="xml"&gt;//Listing - 8, Web.config
&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;xml&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;version&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;1.0"&lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;?&lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;configuration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;  &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;system.serviceModel&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;services&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;service&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;name&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;FirstWcfService.Service"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;ServiceBehavior"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-comment" style="background-color: #9fc5e8;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&lt;span class="code-comment"&gt; Service Endpoints &lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;endpoint&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;address&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;binding&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;basicHttpBinding"&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;           &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;contract&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;FirstWcfService.IService"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;       &lt;/span&gt;&lt;span class="code-comment" style="background-color: #9fc5e8;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&lt;span class="code-comment"&gt; This Endpoint is used for genertaing the proxy for the client &lt;/span&gt;--&amp;gt;&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;
&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;endpoint&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;address&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;mex"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;binding&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;mexHttpBinding"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;contract&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;IMetadataExchange"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;service&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;services&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;behaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;serviceBehaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;behavior&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;name&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;ServiceBehavior"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-comment" style="background-color: #9fc5e8;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&lt;span class="code-comment"&gt; To avoid disclosing metadata information, set the value below to
              false and remove the metadata endpoint above before deployment &lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;serviceMetadata&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;httpGetEnabled&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;true"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-comment" style="background-color: #9fc5e8;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&lt;span class="code-comment"&gt; To receive exception details in faults for debugging purposes,
              set the value below to true.  Set to false before deployment to avoid
              disclosing exception information &lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;serviceDebug&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;includeExceptionDetailInFaults&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;false"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;behavior&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;serviceBehaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;behaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;  &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;system.serviceModel&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;configuration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;h2&gt;

Option 4 – IIS7 (WAS) host application&lt;/h2&gt;
1 - I created here a simple WCF Service web application using windows
 server 2008 (IIS7) and then I have referenced FirstWcfService in order 
to host it as in the following listing – 9:&lt;br /&gt;
&lt;img alt="FirstWcfIIS7Host.PNG" height="134" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/FirstWcfIIS7Host.PNG" width="206" /&gt;&lt;br /&gt;
&lt;pre lang="cs"&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Listing - 9 file Service.svc&lt;/span&gt;
&lt;span class="code-pagedirective"&gt;&amp;lt;%@&lt;/span&gt;&lt;span class="code-leadattribute"&gt; ServiceHost Language&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;C#"&lt;/span&gt;&lt;span class="code-attribute"&gt; Debug&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;true"&lt;/span&gt;&lt;span class="code-attribute"&gt; Service&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;FirstWcfService.Service"&lt;/span&gt;&lt;span class="code-pagedirective"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
2- I have created a configuration file with a minimum configuration options as in the following listing -10:&lt;br /&gt;
&lt;pre lang="xml"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre lang="xml"&gt;//Listing - 10, Web.config
&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;xml&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;version&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;1.0"&lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;?&lt;/span&gt;&lt;span class="code-SummaryComment" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;configuration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;  &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;system.serviceModel&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;services&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;service&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;name&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;FirstWcfService.Service"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;ServiceBehavior"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-comment" style="background-color: #9fc5e8;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&lt;span class="code-comment"&gt; Service Endpoints &lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;endpoint&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;address&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;binding&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;netTcpBinding"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;contract&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;FirstWcfService.IService"&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;            &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;bindingConfiguration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;tcpbinding"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;endpoint&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;address&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;mextcp"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;binding&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;mexTcpBinding"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;contract&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;IMetadataExchange"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;service&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;services&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;behaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;serviceBehaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;behavior&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;name&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;ServiceBehavior"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-comment" style="background-color: #9fc5e8;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&lt;span class="code-comment"&gt; To avoid disclosing metadata information, set the value below to false
              and remove the metadata endpoint above before deployment &lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;serviceMetadata&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;httpGetEnabled&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;true"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-comment" style="background-color: #9fc5e8;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&lt;span class="code-comment"&gt; To receive exception details in faults for debugging purposes,
               set the value below to true.  Set to false before deployment to avoid
               disclosing exception information &lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;serviceDebug&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;includeExceptionDetailInFaults&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;false"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;behavior&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;serviceBehaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;behaviors&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;bindings&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;netTcpBinding&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;binding&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;name&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;tcpbinding"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-comment" style="background-color: #9fc5e8;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&lt;span class="code-comment"&gt;&amp;lt;security mode="None"&amp;gt;&amp;lt;/security&amp;gt;&lt;/span&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;security&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;mode&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;Transport"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;            &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;transport&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;clientCredentialType&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;Windows"&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;protectionLevel&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;EncryptAndSign"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;            &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;message&lt;/span&gt;&lt;span style="background-color: #9fc5e8;"&gt; &lt;/span&gt;&lt;span class="code-attribute" style="background-color: #9fc5e8;"&gt;clientCredentialType&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;="&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;Windows"&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;          &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;security&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;        &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;binding&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;      &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;netTcpBinding&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;    &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;bindings&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="background-color: #9fc5e8;"&gt;  &lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;system.serviceModel&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute" style="background-color: #9fc5e8;"&gt;configuration&lt;/span&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre lang="xml"&gt;&lt;span class="code-keyword" style="background-color: #9fc5e8;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;b&gt;NOTE:&lt;/b&gt;As you can see here, I have done the same 
implementation as I did for option 3 while hosting my SCF service inside
 II6, the only difference is, I have configured my service to be 
callable using “net.Tcp” protocol inside IIS7 (WAS) instead of classic 
“basicHttp” protocol. I’m not going to explain the new architecture of 
IIS7, because this topic is out of scope in this article.&lt;br /&gt;
3- When you create a WCF service inside IIS7, by default this service
 has only http and wshttp enabled. I have configured my service to be 
callable using net.Tcp protocol as in the following steps:&lt;br /&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px;"&gt;
A - in order to enable a new protocol like net.Tcp, we need to add it
 to our default web site tree via IIS Manager by clinking on “Edit 
Bindings”&lt;br /&gt;
&lt;img alt="IIS7Manager1.PNG" height="371" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/IIS7Manager1.PNG" width="529" /&gt;&lt;br /&gt;
&lt;br /&gt;
B - Add the new protocol with the desired port also, I added 9200&lt;br /&gt;
&lt;br /&gt;
&lt;img alt="IIS7Manager3.PNG" height="193" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/IIS7Manager3.PNG" width="471" /&gt;&lt;br /&gt;
&lt;img alt="IIS7Manager2.PNG" height="217" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/IIS7Manager2.PNG" width="404" /&gt;&lt;br /&gt;
&lt;br /&gt;
C – Always from IIS Manager, add the net.Tcp to your WCf service by clicking on advanced settings:&lt;br /&gt;
&lt;img alt="IIS7Manager4.PNG" height="217" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/IIS7Manager4.PNG" width="459" /&gt;&lt;br /&gt;
&lt;br /&gt;
D – write your desired protocol through Enabled protocols settings :&lt;br /&gt;
&lt;img alt="IIS7Manager5.PNG" height="550" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/IIS7Manager5.PNG" width="449" /&gt;&lt;/blockquote&gt;
&lt;h2&gt;

Create the client application &lt;/h2&gt;
&lt;div dir="ltr"&gt;
I created a simple client console application in order to 
show you how we can call our WCF service using multiple hosting options.&lt;br /&gt;
My client application looks like this:&lt;/div&gt;
&lt;div dir="ltr"&gt;
&lt;img alt="FirstWcfServiceClientConsoleApp.PNG" height="195" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/FirstWcfServiceClientConsoleApp.PNG" width="210" /&gt;&lt;/div&gt;
&lt;div dir="ltr"&gt;
Let’s examine this application:&lt;br /&gt;
1 – We need co create a proxy, to create a proxy we have tow possibilities:&lt;br /&gt;
Either from Visual studio by adding a service reference as below :&lt;/div&gt;
&lt;div dir="ltr"&gt;
&lt;img alt="ServiceRef.PNG" height="437" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/ServiceRef.PNG" width="535" /&gt;&lt;/div&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px;"&gt;
&lt;div dir="ltr"&gt;
Or by using the SvcUtil.exe utility, as we have multiple 
hosting options, we can observe here that we need just to use one of the
 following created proxy :&lt;br /&gt;
• If you create the proxy from a service 
hosted inside a console application you make: SvcUtil.exe 
net.tcp://localhost:9100/mex /out:path\proxy.cs /n:*,localhost &lt;br /&gt;
• If 
you create the proxy from a service hosted inside a windows service 
application you make SvcUtil.exe net.tcp://localhost:9000/mex 
/out:path\proxy.cs /n:*,localhost&lt;br /&gt;
• If you create the proxy from a service hosted inside an IIS 6 you make SvcUtil.exe &lt;a href="http://localhost/FirstWcfIISHost/Service.svc"&gt;http://localhost/FirstWcfIISHost/Service.svc&lt;/a&gt; /out:path\proxy.cs /n:*,localhost&lt;br /&gt;
•
 If you create the proxy from a service hosted inside an IIS7 using tcp 
protocol you make SvcUtil.exe 
net.tcp://winserver2008:9200/FirstWcfHost/Service.svc/ out:path\proxy.cs
 /n:*,localhost&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div dir="ltr"&gt;
When you create your proxy for the first time, you can use 
the same proxy to call the same service inside different hosting 
environments.&lt;br /&gt;
Finally our proxy will be as the following listing – 11&lt;/div&gt;
&lt;pre dir="ltr" lang="cs"&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Listing - 11 proxy.cs file&lt;/span&gt;
&lt;span class="code-keyword"&gt;namespace&lt;/span&gt; localhost
{
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;System.ServiceModel"&lt;/span&gt;, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;3.0.0.0"&lt;/span&gt;)]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;localhost.IService"&lt;/span&gt;)]
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;interface&lt;/span&gt; IService
    {
        
        [System.ServiceModel.OperationContractAttribute(Action =
            &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;&lt;a href="http://www.codeproject.com/KB/WCF/%22%3C/span"&gt;%22http:&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;tempuri.org/IService/Hello%22"&amp;gt;http://tempuri.org/IService/Hello&lt;/span&gt;&lt;/a&gt;",&lt;/span&gt;
            ReplyAction = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;&lt;a href="http://www.codeproject.com/KB/WCF/%22%3C/span"&gt;%22http:&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;tempuri.org/IService/HelloResponse%22"&amp;gt;http://tempuri.org/IService/HelloResponse&lt;/span&gt;&lt;/a&gt;")]&lt;/span&gt;
        &lt;span class="code-keyword"&gt;string&lt;/span&gt; Hello();
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;System.ServiceModel"&lt;/span&gt;, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;3.0.0.0"&lt;/span&gt;)]
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;interface&lt;/span&gt; IServiceChannel : localhost.IService,
        System.ServiceModel.IClientChannel
    {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;System.ServiceModel"&lt;/span&gt;, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;3.0.0.0"&lt;/span&gt;)]
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;partial&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; ServiceClient :
        System.ServiceModel.ClientBase&amp;lt;localhost.IService&amp;gt;, localhost.IService
    {
        
        &lt;span class="code-keyword"&gt;public&lt;/span&gt; ServiceClient()
        {
        }
        
        &lt;span class="code-keyword"&gt;public&lt;/span&gt; ServiceClient(&lt;span class="code-keyword"&gt;string&lt;/span&gt; endpointConfigurationName) : 
                &lt;span class="code-keyword"&gt;base&lt;/span&gt;(endpointConfigurationName)
        {
        }
        
        &lt;span class="code-keyword"&gt;public&lt;/span&gt; ServiceClient(&lt;span class="code-keyword"&gt;string&lt;/span&gt; endpointConfigurationName, &lt;span class="code-keyword"&gt;string&lt;/span&gt; remoteAddress) : 
                &lt;span class="code-keyword"&gt;base&lt;/span&gt;(endpointConfigurationName, remoteAddress)
        {
        }
        
        &lt;span class="code-keyword"&gt;public&lt;/span&gt; ServiceClient(&lt;span class="code-keyword"&gt;string&lt;/span&gt; endpointConfigurationName,
            System.ServiceModel.EndpointAddress remoteAddress) : 
                &lt;span class="code-keyword"&gt;base&lt;/span&gt;(endpointConfigurationName, remoteAddress)
        {
        }
        
        &lt;span class="code-keyword"&gt;public&lt;/span&gt; ServiceClient(System.ServiceModel.Channels.Binding binding,
            System.ServiceModel.EndpointAddress remoteAddress) : 
                &lt;span class="code-keyword"&gt;base&lt;/span&gt;(binding, remoteAddress)
        {
        }
        
        &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; Hello()
        {
            &lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-keyword"&gt;base&lt;/span&gt;.Channel.Hello();
        }
    }
}&lt;/pre&gt;
2- I have created a configuration file with a minimum configuration options as in the following listing -12:&lt;br /&gt;
&lt;pre lang="xml"&gt;//Listing - 12, App.config
&lt;span class="code-SummaryComment"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;xml&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;version&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;1.0"&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;encoding&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;utf-8"&lt;/span&gt; &lt;span class="code-SummaryComment"&gt;?&lt;/span&gt;&lt;span class="code-SummaryComment"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;configuration&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;system.serviceModel&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;client&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-comment"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword"&gt;&lt;span class="code-comment"&gt; calling the WCF service which is hosted inside windows console application &lt;/span&gt;--&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;endpoint&lt;/span&gt; &lt;span class="code-attribute"&gt;address&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;net.tcp://localhost:9100/FirstWcfService"&lt;/span&gt; &lt;span class="code-attribute"&gt;binding&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;netTcpBinding"&lt;/span&gt;
          &lt;span class="code-attribute"&gt;contract&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;localhost.IService"&lt;/span&gt; &lt;span class="code-attribute"&gt;name&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Windows_Console_Host_TcpBinding"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;endpoint&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-comment"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword"&gt;&lt;span class="code-comment"&gt; calling the WCF service which is hosted inside IIS6 &lt;/span&gt;--&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;endpoint&lt;/span&gt; &lt;span class="code-attribute"&gt;address&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;&lt;a href="http://www.codeproject.com/KB/WCF/%22%3C/span"&gt;&lt;span class="code-attribute"&gt;%22http:&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-attribute"&gt;localhost&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-attribute"&gt;FirstWcfIISHost&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-attribute"&gt;Service.svc%22"&amp;gt;http:&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-attribute"&gt;localhost&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-attribute"&gt;FirstWcfIISHost&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-attribute"&gt;Service.svc&lt;/span&gt;&lt;/a&gt;"&lt;/span&gt;
          &lt;span class="code-attribute"&gt;binding&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;basicHttpBinding"&lt;/span&gt;
          &lt;span class="code-attribute"&gt;contract&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;localhost.IService"&lt;/span&gt; &lt;span class="code-attribute"&gt;name&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;IIS_Host_HttpBinding"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;endpoint&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-comment"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword"&gt;&lt;span class="code-comment"&gt; calling the WCF service which is hosted inside windows service  &lt;/span&gt;--&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;endpoint&lt;/span&gt; &lt;span class="code-attribute"&gt;address&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;net.tcp://localhost:9000/FirstWcfService"&lt;/span&gt;
          &lt;span class="code-attribute"&gt;binding&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;netTcpBinding"&lt;/span&gt;
          &lt;span class="code-attribute"&gt;contract&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;localhost.IService"&lt;/span&gt; &lt;span class="code-attribute"&gt;name&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Windows_Services_Host_TcpBinding"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;endpoint&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-comment"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword"&gt;&lt;span class="code-comment"&gt; calling the WCF service which is hosted inside IIS7 (WAS)  &lt;/span&gt;--&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;endpoint&lt;/span&gt; &lt;span class="code-attribute"&gt;address&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;net.tcp://winserver2008:9200/FirstWcfHost/Service.svc"&lt;/span&gt;
          &lt;span class="code-attribute"&gt;binding&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;netTcpBinding"&lt;/span&gt;
          &lt;span class="code-attribute"&gt;contract&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;localhost.IService"&lt;/span&gt; &lt;span class="code-attribute"&gt;name&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;II7_WAS_Host_TcpBinding"&lt;/span&gt;
          &lt;span class="code-attribute"&gt;bindingConfiguration&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;II7NetTcpBinding"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;endpoint&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;client&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;bindings&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;netTcpBinding&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;binding&lt;/span&gt; &lt;span class="code-attribute"&gt;name&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;II7NetTcpBinding"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="code-comment"&gt;&amp;lt;!--&lt;/span&gt;&lt;span class="code-keyword"&gt;&lt;span class="code-comment"&gt;&amp;lt;security mode="None"&amp;gt;&amp;lt;/security&amp;gt;&lt;/span&gt;--&amp;gt;&lt;/span&gt;
          &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;security&lt;/span&gt; &lt;span class="code-attribute"&gt;mode&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Transport"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;transport&lt;/span&gt; &lt;span class="code-attribute"&gt;clientCredentialType&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Windows"&lt;/span&gt;
                         &lt;span class="code-attribute"&gt;protectionLevel&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;EncryptAndSign"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;message&lt;/span&gt; &lt;span class="code-attribute"&gt;clientCredentialType&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Windows"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;security&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;binding&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;netTcpBinding&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;bindings&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;system.serviceModel&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;configuration&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div lang="xml"&gt;
In this file I have configured my client in order to show 
you how we can call the same WCF service hosted in different 
environments. In realty you do not need all these endpoints, you need 
only one of these endpoints for your client, so your “app.config” would 
be as in following listing - 13: &lt;/div&gt;
&lt;pre lang="xml"&gt;&lt;span class="code-pagedirective"&gt;&amp;lt;?&lt;/span&gt;x ml version=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;1.0"&lt;/span&gt; encoding=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;utf-8"&lt;/span&gt; ?&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;configuration&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;system.serviceModel&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;client&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;!-- calling the WCF service which is hosted inside windows console application --&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;endpoint address=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;net.tcp://localhost:9100/FirstWcfService"&lt;/span&gt; binding=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;netTcpBinding"&lt;/span&gt;
          contract=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;localhost.IService"&lt;/span&gt; name=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Windows_Console_Host_TcpBinding"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/endpoint&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/client&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/system.serviceModel&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;/configuration&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
3- I have implemented my client as in the following listing -14:&lt;br /&gt;
&lt;pre lang="cs"&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Listing - 14, Program.cs&lt;/span&gt;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; System;
&lt;span class="code-keyword"&gt;namespace&lt;/span&gt; FirstWcfServiceClientConsoleApp
{
    &lt;span class="code-keyword"&gt;class&lt;/span&gt; Program
    {
        &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; Main(&lt;span class="code-keyword"&gt;string&lt;/span&gt;[] args)
        {
            &lt;span class="code-keyword"&gt;try&lt;/span&gt;
            {
                &lt;span class="code-preprocessor"&gt;#region&lt;/span&gt; Call the hosted service inside IIS6
                localhost.ServiceClient iis6proxy = &lt;span class="code-keyword"&gt;new&lt;/span&gt; localhost.ServiceClient(
                    &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;IIS_Host_HttpBinding"&lt;/span&gt;);
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;====================="&lt;/span&gt;);
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Call the hosted service inside IIS6"&lt;/span&gt;);
                Console.WriteLine(iis6proxy.Hello());
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;====================="&lt;/span&gt;);
                Console.WriteLine();
                &lt;span class="code-preprocessor"&gt;#endregion&lt;/span&gt;
                &lt;span class="code-preprocessor"&gt;#region&lt;/span&gt; Call the hosted service inside IIS7 (WAS)
                localhost.ServiceClient iis7proxy = &lt;span class="code-keyword"&gt;new&lt;/span&gt; localhost.ServiceClient(
                    &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;II7_WAS_Host_TcpBinding"&lt;/span&gt;);
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;====================="&lt;/span&gt;);
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Call the hosted service inside IIS7 (WAS)"&lt;/span&gt;);
                Console.WriteLine(iis7proxy.Hello());
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;====================="&lt;/span&gt;);
                Console.WriteLine();
                &lt;span class="code-preprocessor"&gt;#endregion&lt;/span&gt;
                &lt;span class="code-preprocessor"&gt;#region&lt;/span&gt; Call the hosted service inside Windows service application
                localhost.ServiceClient tcpWindowsSrviceproxy =
                    &lt;span class="code-keyword"&gt;new&lt;/span&gt; localhost.ServiceClient(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Windows_Services_Host_TcpBinding"&lt;/span&gt;);
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;====================="&lt;/span&gt;);
                Console.WriteLine(
                    &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Call the hosted service inside Windows service application"&lt;/span&gt;);
                Console.WriteLine(tcpWindowsSrviceproxy.Hello());
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;====================="&lt;/span&gt;);
                Console.WriteLine();
                &lt;span class="code-preprocessor"&gt;#endregion&lt;/span&gt;
                &lt;span class="code-preprocessor"&gt;#region&lt;/span&gt; Call the hosted service inside Windows Console application
                localhost.ServiceClient tcpproxy = &lt;span class="code-keyword"&gt;new&lt;/span&gt; localhost.ServiceClient(
                     &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Windows_Console_Host_TcpBinding"&lt;/span&gt;);
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;====================="&lt;/span&gt;);
                Console.WriteLine(
                    &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Call the hosted service inside Windows Console application"&lt;/span&gt;);
                Console.WriteLine(tcpproxy.Hello());
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;====================="&lt;/span&gt;);
                Console.WriteLine();
                Console.WriteLine(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Press &amp;lt;Enter&amp;gt; to terminate the client application."&lt;/span&gt;);
                Console.ReadLine();
                &lt;span class="code-preprocessor"&gt;#endregion&lt;/span&gt;
            }
            &lt;span class="code-keyword"&gt;catch&lt;/span&gt; (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
    }
}&lt;/pre&gt;
In the above code, we notice that in order to call a WCF service, we need to instantiate the proxy class like this :&lt;br /&gt;
localhost.ServiceClient iis6proxy = new localhost.ServiceClient("IIS_Host_HttpBinding");&lt;br /&gt;
and then we can call a function or method we are interested like this:&lt;br /&gt;
iis6proxy.Hello());&lt;br /&gt;
&lt;h2&gt;

Putting all together and get the result&lt;/h2&gt;
My final solution will be something like that:&lt;br /&gt;
&lt;img alt="FirstWcfServiceSolution.PNG" height="116" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/FirstWcfServiceSolution.PNG" width="233" /&gt;&lt;br /&gt;
Finally when we run the client application 
(FirstWcfServiceClientConsoleApp.exe) after verifying that all four 
hosting environments (IIS6, IIS7, windows service, windows console 
application) are running and listening, we get the following wonderful 
result:&lt;br /&gt;
&lt;img alt="ClientResult.PNG" height="330" src="http://www.codeproject.com/KB/WCF/WCFMultipleHosting/ClientResult.PNG" width="668" /&gt;&lt;br /&gt;
&lt;div dir="ltr" style="margin-right: 0px;"&gt;
As you can notice here, we have 
created a WCF service, hosted it in four different environments as below
 using different protocols :&lt;/div&gt;
&lt;div style="margin-right: 0px;"&gt;
- Windows a console application using tcp protocol&lt;br /&gt;
- Windows service process using tcp protocol&lt;br /&gt;
- IIS6 using http protocol&lt;br /&gt;
- IIS7 using tcp protocol&lt;/div&gt;
&lt;div dir="ltr" style="margin-right: 0px;"&gt;
By changing only the endpoint on the client we have been able to access our WCF service and calling functions. &lt;br /&gt;
What
 I do like to precise here, different client applications (Windows, 
Intranet, Internet, Extranet, ..etc) can call the service in different 
hosting environments.&lt;br /&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-3132757318462723768?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/P122ld_zLFxg00UyNO6okk-5HA8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/P122ld_zLFxg00UyNO6okk-5HA8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/P122ld_zLFxg00UyNO6okk-5HA8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/P122ld_zLFxg00UyNO6okk-5HA8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/Gf4DnUxUAlo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/3132757318462723768/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=3132757318462723768" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/3132757318462723768?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/3132757318462723768?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/Gf4DnUxUAlo/host-wcf-service-with-multiple-host.html" title="Host WCF service with multiple host environment using multiple protocol" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/host-wcf-service-with-multiple-host.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MDSHs4eSp7ImA9WhdVEUg.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-3304293117021258006</id><published>2011-09-16T12:48:00.000+05:30</published><updated>2011-09-16T13:21:19.531+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-16T13:21:19.531+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="IIS" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>Remote IIS Debugging : Debug your ASP.NET Application which is hosted on "Remote IIS Server"</title><content type="html">&lt;br /&gt;
&lt;h2&gt;


&lt;b&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="2"&gt;Introduction :&lt;/a&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&lt;/h2&gt;
Before starting with this article, I will request&amp;nbsp;you to read my previous article
&lt;a href="http://challadotnetfaq.blogspot.com/2011/09/aspnet-debugging-vs-iis-debugging.html"&gt;Debug Your  ASP.NET Application that Hosted on IIS : Process Attach and Identify which  process to attach&lt;/a&gt; . This article will give you the basic understanding of 
Debugging ASP.NET Application that is hosted on Local Server, along with Process 
selection among multiple processes. And article was all about if you have IIS 
installed in local server, that means you have hosted your site on your local 
development environment or your Web server/ production server having visual 
studio installed. But this is not the real scenario.&lt;br /&gt;
Now coming back to this article, this article is all 
about the IIS&amp;nbsp; remote debugging. You are developing your application in you 
local system which is hosted on remote web server and now you need to debug it. 
How will you do that ? This article will describe all the necessary steps 
like &lt;i&gt;how to configure remote debugging&lt;/i&gt;, &lt;i&gt;attaching process from remote server&lt;/i&gt;, 
&lt;i&gt;start debugging&lt;/i&gt; etc. This is one of the most challenging task in ASP.NET. &lt;br /&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="3"&gt;Visual Studio Debugging 
Features for ASP.NET&lt;/a&gt;&lt;/b&gt;&amp;nbsp;&lt;/h2&gt;
We can have three different way to debug our 
application from Visual Studio. They are:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Visual Studio Internal Debugger&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&lt;code&gt;Local IIS Debugging&lt;/code&gt;&amp;nbsp;&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;Remote IIS Debugging&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="4"&gt;Visual Studio Internal Debugger :&amp;nbsp;&lt;/a&gt;&lt;/b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="4"&gt;&amp;nbsp;&lt;/a&gt;&lt;/h4&gt;
We are all aware of that visual studio is having 
its own internal &lt;code&gt;ASP.NET debug engine&lt;/code&gt; which is used to debug our ASP.NET web 
application while we are developing it. The process which is used to debug the 
application within visual studio is &lt;code&gt;WebDev.WebServer.Exe &lt;/code&gt;
. ASP.NET Engine uses &lt;code&gt;WebDev.WebServer.exe&lt;/code&gt; to 
debug the application.&lt;br /&gt;
Now if you want to know more details about it please read
&lt;a href="http://challadotnetfaq.blogspot.com/2011/09/aspnet-debugging-vs-iis-debugging.html"&gt;this&lt;/a&gt; .&lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="remote4.jpg" height="252" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote4.jpg" width="496" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&lt;b&gt;Fig:&lt;/b&gt; Block Diagram for Visual 
Studio Internal Debugger&lt;/div&gt;
&lt;h4&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="5"&gt;Local IIS Debugging&amp;nbsp; :&lt;/a&gt;&lt;/b&gt;&lt;/h4&gt;
I am explaining the whole scenario using following 
diagram.&lt;br /&gt;
&lt;div align="center"&gt;
&lt;br /&gt;
&lt;img alt="remote5.jpg" height="297" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote5.jpg" width="519" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&lt;b&gt;Fig:&lt;/b&gt; Block Diagram for Debugging 
ASP.NET site from Local IIS Server&lt;/div&gt;
&lt;div align="left"&gt;
In local IIS debugging, IIS should 
be installed in the local system where we have visual studio installed. For 
debugging the application hosted on IIS from visual studio, we need to 
attach the worker process (&lt;code&gt;w3wp.exe&lt;/code&gt;) with in visual studio. After that we will 
able to start the debugging of the web application.&lt;/div&gt;
&lt;h4&gt;


&lt;b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;h4&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="6"&gt;Remote IIS Debugging :&lt;/a&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;div align="left"&gt;
This is the main topic which we 
should cover in this article. It is one of the best features and it is very much&amp;nbsp; 
helpful when &lt;i&gt;we do not&amp;nbsp;have a IIS Server installed&lt;/i&gt; in local system or when 
we have to store the applications at a centralized location. The scenario comes 
when&amp;nbsp;you are having with your application code in your system and the 
build which was deployed on different IIS server. Below diagrams shows the 
overall diagram for remote debugging.&lt;/div&gt;
&lt;div align="center"&gt;
&lt;img alt="remote6.jpg" height="464" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote6.jpg" width="639" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&lt;b&gt;Fig:&lt;/b&gt; Block Diagram for Remote 
debugging of ASP.NET Application&lt;/div&gt;
&lt;div align="left"&gt;
Remote debugging with Visual 
studio and Remote IIS is very easy to setup. The tool which is used to setup and 
configure the process is know as &lt;code&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;msvsmon.exe"&lt;/span&gt;&lt;/code&gt;. I have describe each and every 
steps to start, configure&amp;nbsp; the msvsmon tool and debug the application. But 
before that just have a look on why should we need remote debugging.&lt;/div&gt;
&lt;div align="left"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="7"&gt;Why Remote 
Debugging :&lt;/a&gt; &lt;/b&gt;&lt;/h2&gt;
&lt;div align="left"&gt;
Before going into details, we 
    need to know when we have to use remote debugging,&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
	&lt;div align="left"&gt;
Local development server does 
	not have IIS installed.
	&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
	&lt;div align="left"&gt;
Development server and 
	Build/Released/Hosting Server is different
	&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
	&lt;div align="left"&gt;
Application located in 
	centralized location.&amp;nbsp;&lt;/div&gt;
&lt;div align="left"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="8"&gt;Remote 
Debugging Tool&lt;/a&gt;&lt;/b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="8"&gt;&amp;nbsp;&lt;/a&gt;&lt;/h2&gt;
&lt;div align="left"&gt;
The tool which is used to remote 
debugging of the ASP.Net application know as "&lt;code&gt;Msvsmon.exe&lt;/code&gt;" . 
The Remote Debugging tool (&lt;code&gt;Msvsmon.exe&lt;/code&gt;) is a small windows based application 
that Visual Studio 2005 uses for remote debugging. It has very simple UI 
which makes it very simple to setup and configure During remote debugging, 
Visual Studio 2005 runs on one computer&amp;nbsp;and the Remote Debugging Tool runs on 
the remote computer along with the application you are debugging. &lt;/div&gt;
&lt;div align="center"&gt;
&lt;img alt="remote7.jpg" height="219" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote7.jpg" width="631" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&lt;b&gt;Fig:&lt;/b&gt; Block Diagram for Remote 
debugging of ASP.NET Application with msvsmon&lt;/div&gt;
&lt;div align="left"&gt;
If we want to debug the 
application which is hosted on remote IIS, we have to start the msvsmon.exe to 
the remote server, and our development system is the debugger host where we will 
debug our code.&amp;nbsp;&lt;/div&gt;
&lt;div align="left"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="10"&gt;Start 
msvsmon.exe &lt;/a&gt; &lt;/b&gt;&lt;/h2&gt;
Msvsmon.exe is installed to the following paths:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&lt;code&gt;
	Install path\Microsoft Visual Studio 
	8\Common7\IDE\Remote Debugger\x86&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;/code&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
First of all we need to Run the Application 
from the location and we will get following screen,&lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="remote8.jpg" height="200" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote8.jpg" width="743" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;&lt;b&gt;Fig:&lt;/b&gt; Initial startup of msvsmon.exe&lt;/div&gt;
At the time of starting of application the 
window will show the status message &lt;code&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Msvsmon started a new server named '&lt;b&gt;&lt;code&gt;&amp;lt;ServerName&amp;gt;&lt;/code&gt;&lt;/b&gt;&lt;/span&gt;&lt;/code&gt;&lt;b&gt;&lt;/b&gt;'. 
Waiting for new connection". Which means Debugging monitor tool&amp;nbsp;is ready 
to connect with some remote server. Now I can connect with this remote server 
and get the list of all process that is running on the server.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="11"&gt;Configure Authentication 
Mode&lt;/a&gt;&lt;/b&gt;&amp;nbsp;&lt;/h2&gt;
Configuration of msvsmon tool is very easy. The 
main configuration is involves with the authentication mode. Msvsmon support&amp;nbsp;two types of authentication&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Windows Authentication&lt;/code&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;No-Authentication&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;

&lt;b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;h4&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="12"&gt;Windows Authentication&lt;/a&gt;&lt;/b&gt;&amp;nbsp;&lt;/h4&gt;
Msvsmon provide highlevel security with the windows
    authentication mode. The user who want to debug the application remotely he should
    be authenticated, means he should have sufficient permission to access the debugging
    facility from the remote system. For Setup the Windows authentication mode, We have
    go &lt;code&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Tool"&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Options"&lt;/span&gt;&lt;/code&gt; . Following window will appear,&lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="remote9.JPG" height="300" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote9.JPG" width="413" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&lt;br /&gt;
&lt;b&gt;Fig:&lt;/b&gt; Setup and configure security settings&lt;/div&gt;
&lt;div class="style1"&gt;
Now we have a permission button along with the windows authentication radio button.
        Using that, we can give permission to any user who belongs to that windows group.
        If we click on the Permission button, following screen will appear&lt;/div&gt;
&lt;div align="center"&gt;
&lt;img alt="remote10.JPG" height="443" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote10.JPG" width="367" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Add user for windows authentication&lt;/div&gt;
By default, Administrator should have the permission for
            remote debugging, we can use add button to add new user and can give the &lt;i&gt;Debug access
            or Deny the Debug persmission&lt;/i&gt; to any user. For example, I have added myself
            by just clicking on Add button and take the access control.&lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="Remote11.JPG" height="245" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/Remote11.JPG" width="461" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Add user for windows authentication &lt;/div&gt;
&lt;br /&gt;
Now, I have give me the permission for debugging from
            remotely (from Debugger Host). &lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="remote12.JPG" height="42" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote12.JPG" width="334" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Debug permission for selected user&lt;/div&gt;
Similiarly we can select any user from Active Directory and can deny
            the request for remote debugging though the user is Windows authenticated user.&lt;br /&gt;
I have discussed about how to debug remotely with windows authentication mode in
        the process attache section.&lt;br /&gt;
&lt;h4&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="13"&gt;No-Authentication&lt;/a&gt;&lt;/b&gt;&amp;nbsp;&lt;/h4&gt;
&lt;div align="left"&gt;
There is no security involved with this authentication
    mode. Any one can debug remotely, if the authentication mode is set to &lt;code&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;No-Authentication"&lt;/span&gt;&lt;/code&gt;.
    As this debugging mode is not at all secure, so it should be used only on secure
    network.&lt;/div&gt;
&lt;div align="center"&gt;
&lt;img alt="remote13.JPG" height="300" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote13.JPG" width="413" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; No-Authentication Mode Configuration&lt;/div&gt;
No 
Authentication mode only supports native debugging.
            You can also guess the behaviour from the warning message. We have a "&lt;code&gt;Allow any
            User to Debug&lt;/code&gt;" check box. If we checked that one, any user can able to debug.&lt;br /&gt;
In the next section I have described, how to attach the process for remote debugging
        for both Windows and No Authentication Mode.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="14"&gt;Attach Process from Remote System&lt;/a&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;br /&gt;
Now, Remote Debugger is ready to accept a new connection to start remote debugging.
        And we have already gone through how to configure the msvsmon for both windows and
        No-Authentication mode. Now we will check how to connect with them and start debugging,
		
    &lt;br /&gt;
Before what we need to do, we have created a Web application and hosted it IIS where
        msvsmon is running, We need to connect it from our local system where we are having
        our code. Now lets have a look in the case of&amp;nbsp; windows authentication mode&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


&lt;b&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;code&gt; &lt;/code&gt;&lt;/code&gt;&lt;code&gt;&lt;code&gt;&lt;code&gt;&lt;code&gt;&lt;a class="code-string" href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="&amp;lt;span"&gt;"&lt;span class="code-string"&gt;15"&lt;/span&gt;&amp;gt;Process Attach - Windows Authentication Mode&lt;/a&gt;&lt;/code&gt;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/code&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;h3&gt;


&lt;b&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;b&gt; 
		&lt;/b&gt;
    &lt;br /&gt;
First of all we need to open the application 
		from visual studio in our development system. Now we need to attach the 
		process from remote server.&amp;nbsp; Goto &lt;code&gt;Tool &lt;/code&gt;&amp;gt; &lt;code&gt;Attach Process&lt;/code&gt;&lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="remote15.jpg" height="92" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote15.jpg" width="641" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Attach Process From Visual Studio&lt;/div&gt;
&lt;div align="left"&gt;
When we will click on the "&lt;code&gt;Attach to 
		Process&lt;/code&gt;" we will get the following screen .&lt;/div&gt;
&lt;div align="center"&gt;
&lt;img alt="remote16.jpg" height="490" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote16.jpg" width="486" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Default Process List &lt;/div&gt;
Right now it is showing all the process 
		that are currently running on the system. Now we need to 
		connect it the remote system. Now I have already started a msvsmon with 
		name &lt;code&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;abhijit.jana"&lt;/span&gt;&lt;/code&gt; and it is waiting for a new connection.&lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="remote8.jpg" height="200" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote8.jpg" width="743" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; msvsmon is running on remote host&lt;/div&gt;
&lt;div align="left"&gt;
Now, I am going to connect with the remote 
		system from my local visual studio IDE. So, what we need to do. We have 
		to give the remote server name to the Qualifier section in attach 
		process window.&lt;/div&gt;
&lt;div align="center"&gt;
&lt;img alt="remote17.jpg" height="439" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote17.jpg" width="607" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Connect with Remote host and get the list of process&lt;/div&gt;
&lt;div align="left"&gt;
&amp;nbsp;Now, in the process list all the 
		process are listed from remote server along with Worker Process 
		(&lt;i&gt;&lt;code&gt;(w3wp.exe&lt;/code&gt;&lt;/i&gt;). Now this is the exact worker process which we need to attach 
		with our code. One more thing, when we are getting the list of process 
		from it means remote server is connected. Now if we check the msvsmon 
		window, it will show another message that user is connected. Have 
		a look into the screenshot&lt;/div&gt;
&lt;div align="center"&gt;
&lt;img alt="remote18.jpg" height="202" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote18.jpg" width="745" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Debug monitor showing message of connection&lt;/div&gt;
Now, our application is ready to debug. 
		just set a break point in your code and enjoy the debugging.&amp;nbsp; Here 
		is our web site [ &lt;i&gt;&lt;code&gt;Hosted on Remote IIS Server &lt;/code&gt;&lt;/i&gt;] and which having a 
		server side button, and I want to debug the application on the click of 
		button. &lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="remote19.jpg" height="193" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote19.jpg" width="376" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Access site from Host URL&lt;/div&gt;
Now process is attached in our visual 
		studio and I have set the breakpoint on the button click method. Here is 
		outcome.&lt;br /&gt;
&lt;img alt="remote20.jpg" height="81" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote20.jpg" width="571" /&gt;&lt;br /&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Debugger at breakpoint&lt;/div&gt;
So, let enjoy the debugging from remote 
		server . Now lets have a look how will we remote debug in 
		&lt;code&gt;No-Authentication mode&lt;/code&gt;.&lt;br /&gt;
&lt;b&gt;&lt;code&gt; &lt;a class="code-string" href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="&amp;lt;span"&gt;"&lt;span class="code-string"&gt;16"&lt;/span&gt;&amp;gt;Process Attach - No Authentication Mode&lt;/a&gt;&lt;/code&gt;
		&lt;/b&gt;&lt;br /&gt;
This is quite similar to windows 
		authentication process attach. I have already discussed that, how to 
		configure the No-Authentication mode in remote debugger. We have to 
		attach the process similar way that I have discussed. There are some few 
		changes. Transport mode should be selected to -&lt;i&gt;&lt;code&gt;Remote (Native only with 
		no authentication)&lt;/code&gt;&lt;/i&gt; [ Check the Screen shots] .And we need 
		to provide the qualifier "&lt;code&gt;&lt;code&gt;abhijit.jana: &lt;span class="code-digit"&gt;4015&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;". Have a look into screen 
		shots,&lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="remote21.jpg" height="338" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote21.jpg" width="722" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Process Attach for No-Authentication Mode&lt;/div&gt;
So, now we need to attach the worker 
		process and need to start debugging, on which I have already discussed. 
		There is slight change in connect while remote debugging going on with 
		No-Authentication mode. Debugging monitor will display a message on 
		the window that debugging is running on no authentication mode.&lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="remote22.jpg" height="110" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/remote22.jpg" width="602" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Status message for No-Authentication Mode&lt;/div&gt;
So, this is all about how to debug you 
		application from remote IIS server in both windows and No-Authentication 
		mode.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="17"&gt;Debugging For Multiple User&amp;nbsp;&lt;/a&gt;&lt;/h2&gt;
&lt;div class="style2"&gt;
This is one of the most fantastic features of 
Msvsmon tool. &lt;i&gt;Msvsmon debugging monitor tool allow multiple user to debug 
simultaneously&lt;/i&gt;. . Each instance of the remote 
debugger has a &lt;code&gt;unique server name&lt;/code&gt;. As I have already shown that Server names are configurable, so 
    we&amp;nbsp; can 
give an instance of the remote debugger any server name. Now multiple user can able 
    to access the same  &lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;div align="center"&gt;
&lt;b&gt; &lt;img alt="Remote25.JPG" height="379" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/Remote25.JPG" width="522" /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; General block diagram from Multiple Debugger instance&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="18"&gt;Some Important Tips while 
remote debugging&lt;/a&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Visual Studio 2005 remote debugging components 
        must be installed on the remote computer&lt;/li&gt;
&lt;li&gt;we must reference the remote computer by 
	using a computer name instead of an IP address.&lt;/li&gt;
&lt;li&gt;The Web.config file for the ASP.NET 
	application must not contain any errors, and the compilation element must 
	have the debug attribute set to True.&lt;/li&gt;
&lt;li&gt;Make sure that a firewall is not blocking 
	remote debugging.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;The security setting for the site must 
	allow Integrated Windows authentication. &lt;/li&gt;
&lt;li&gt;Make sure that the Remote Debugging 
	Monitor is running on the remote server. If Msvsmon.exe is not running, then you will receive the error message.&lt;/li&gt;
&amp;nbsp;&lt;/ul&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="19"&gt;Summary :&lt;/a&gt;&lt;/b&gt;&amp;nbsp;&lt;/h2&gt;
Now to finalize the things, just take a quick 
    summary. msvsmon is an utility which provides the facility to debug the 
    application which is hosted on remote IIS server. It provides two kind of 
    authentication mode, Windows and No-Authentication Mode. In Case of windows 
    authentication mode the user should need the permission to access the instance 
    of remote debugger but on the other hand No-Authentication does not required and 
    security permission.&lt;br /&gt;
&lt;div align="center"&gt;
&lt;img alt="Remote26.JPG" height="321" src="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging/Remote26.JPG" width="495" /&gt;&lt;/div&gt;
&lt;div align="center"&gt;
&amp;nbsp;
        &lt;b&gt;Fig:&lt;/b&gt; Overall Summary&lt;/div&gt;
&lt;br /&gt;
Hope this article will help you 
    to learn about remote debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="20"&gt;Reference :&lt;/a&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/2ys11ead.aspx"&gt;&amp;nbsp;Remote Debugging Errors and Troubleshooting&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.codeproject.com/KB/aspnet/IISRemoteDebugging.aspx"&gt;&amp;nbsp;Remote Debugging &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-3304293117021258006?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/EqTH4pTc4xQDwKxoQbVtQm-5hcE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EqTH4pTc4xQDwKxoQbVtQm-5hcE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/EqTH4pTc4xQDwKxoQbVtQm-5hcE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EqTH4pTc4xQDwKxoQbVtQm-5hcE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/le0qlyRP7H4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/3304293117021258006/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=3304293117021258006" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/3304293117021258006?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/3304293117021258006?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/le0qlyRP7H4/remote-iis-debugging-debug-your-aspnet.html" title="Remote IIS Debugging : Debug your ASP.NET Application which is hosted on &quot;Remote IIS Server&quot;" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><georss:featurename>Hyderabad, Andhra Pradesh, India</georss:featurename><georss:point>17.385044 78.486671</georss:point><georss:box>17.142593 78.17081400000001 17.627495 78.802528</georss:box><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/remote-iis-debugging-debug-your-aspnet.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8NR3w5fSp7ImA9WhdWFE0.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-5612077304937729395</id><published>2011-09-07T18:33:00.000+05:30</published><updated>2011-09-07T18:38:16.225+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-07T18:38:16.225+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="IIS" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>ASP.NET Debugging vs. IIS Debugging</title><content type="html">&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="1"&gt;Overview&lt;/a&gt;&lt;/h2&gt;
Generally we debug our &lt;span class="search-highlight"&gt;ASP.NET&lt;/span&gt; web application from Visual Studio. Visual Studio has its own &lt;span class="search-highlight"&gt;ASP.NET&lt;/span&gt; engine, which is capable enough to run and debug your web &lt;span class="search-highlight"&gt;sites&lt;/span&gt;
 inside Visual Studio. However, if your site is hosted on IIS and you 
want to debug that site directly, how would you debug it? When we host &lt;span class="search-highlight"&gt;sites&lt;/span&gt; on IIS, the Worker Process (&lt;i&gt;w3wp.exe&lt;/i&gt;)
 is used to run the web application. We need to attach to this 
particular process from Visual Studio to debug the web application. This
 article describes the overall idea of debugging an application using 
this method. It also describes the &lt;i&gt;Worker Process&lt;/i&gt;, &lt;i&gt;Application Pool&lt;/i&gt; and selecting a particular process if there are multiple Worker Processes running on IIS, using &lt;code&gt;iisapp.vbs&lt;/code&gt;. I hope you will enjoy this article and provide your valuable suggestions and feedback. &lt;br /&gt;
&lt;h2&gt;


&lt;span class="search-highlight"&gt;&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;
&lt;h2&gt;
&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="2"&gt;&lt;span class="search-highlight"&gt;ASP.NET&lt;/span&gt; Debugging vs. IIS Debugging&lt;/a&gt;&lt;/h2&gt;
Visual Studio has its own integrated debugging engine, which debugs 
our code when we run the application in Visual Studio. If we are 
developing a site and need to debug the code, we just set breakpoints 
and do the debugging (&lt;b&gt;Note&lt;/b&gt;: In this article I do not describe how to set the debug mode). &lt;br /&gt;
When we run the application, execution breaks when certain a breakpoint is reached. It is very simple, because when an &lt;span class="search-highlight"&gt;ASP.NET&lt;/span&gt; application is running in Visual Studio, it is under the control of the &lt;i&gt;&lt;span class="search-highlight"&gt;ASP.NET&lt;/span&gt; Engine&lt;/i&gt;
 which is integrated with Visual Studio. If you want to check which 
process is running for debugging, run the web application from Visual 
Studio: you will get a popup notification as shown below. &lt;br /&gt;
&lt;img height="98" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg1.jpg" width="258" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 1: Taskbar popup when debugging is started from Visual Studio&lt;/div&gt;
This indicates a process is starting to run the &lt;span class="search-highlight"&gt;ASP.NET&lt;/span&gt; application. Double-click on the icon and a popup window will appear to show the details.&lt;br /&gt;
&lt;img height="275" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg2.jpg" width="501" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 2: Development Server process details&lt;/div&gt;
Behind the running process is &lt;i&gt;WebDev.WebServer.exe&lt;/i&gt;. When We press &lt;b&gt;F5&lt;/b&gt;
 to run the application, this process starts to execute the it. If you 
want run the application from command prompt, you have to perform the 
following steps.&lt;br /&gt;
&lt;h4&gt;


Steps to run a web application from the command prompt:&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Open The Visual Studio command prompt &lt;/li&gt;
&lt;li&gt;Run &lt;i&gt;WebDev.WebServer&lt;/i&gt; &lt;/li&gt;
&lt;/ol&gt;
The following screen will come up. Check the &lt;i&gt;Example&lt;/i&gt; section there.&lt;br /&gt;
&lt;img height="336" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg3.jpg" width="556" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 3: WebDev.WebServer usage notification&lt;/div&gt;
Now back to IIS debugging. IIS comes into the picture when we deploy 
or host the site. After deploying the site on IIS, if we want to debug 
the site there, we can't do it directly as in Visual Studio. IIS has its
 own&lt;code&gt; &lt;/code&gt;&lt;i&gt;Worker Process&lt;/i&gt; which takes care of all 
execution and maintenance of deployed web applications. I will describe 
the details of the Worker Process in a later section. So, if we have 
running process in IIS and we need to debug the application, first of 
all we have to attach to the correct process from Visual Studio. Before 
describing that, let's just have a look at the &lt;i&gt;Worker Process&lt;/i&gt; and &lt;i&gt;Application Pool&lt;/i&gt;.&lt;br /&gt;
&lt;h2&gt;


&amp;nbsp;&lt;/h2&gt;
&lt;h2&gt;
&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="3"&gt;What is the Worker Process?&lt;/a&gt;&lt;/h2&gt;
The Worker Process (&lt;i&gt;w3wp.exe&lt;/i&gt;) runs &lt;span class="search-highlight"&gt;ASP.NET&lt;/span&gt; applications within IIS. All &lt;span class="search-highlight"&gt;ASP.NET&lt;/span&gt;
 functionality runs under the scope of the Worker Process. When a 
request comes to the server from a client, the Worker Process is 
responsible for generating the request and response. Its also maintains 
the &lt;i&gt;InProc&lt;/i&gt; session data. If we recycle the Worker Process, we will lose its state. For more information, read this article: &lt;a href="http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp"&gt;A Low-Level Look at the &lt;span class="search-highlight"&gt;ASP.NET&lt;/span&gt; Architecture&lt;/a&gt;&lt;br /&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;
&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="4"&gt;Application Pool&lt;/a&gt; &lt;/h3&gt;
This is one of the most important things that you should create for 
your own application in a production environment. Application Pools are 
used to separate sets of IIS Worker Processes that share the same 
configuration. Application Pools enable us to isolate our web 
application for better security, reliability, and availability. The 
Worker Process serves as the process boundary that separates each 
Application Pool, so that when one Worker Process or application has an 
issue or recycles, other applications or Worker Processes are not 
affected.&lt;br /&gt;
&lt;img border="0" height="231" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/explor42.jpg" width="268" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 4: Relationship between Application Pool and worker process in IIS&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;
&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="6"&gt;Default Application Pool&lt;/a&gt;&lt;/h3&gt;
The name of the default application of IIS 6.0 is &lt;i&gt;DefaultAppPool&lt;/i&gt;.
 After hosting the site on IIS, if we check the properties of the 
virtual directory, we can to view that information as follows.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;i&gt;Start&lt;/i&gt; Menu → &lt;i&gt;Run&lt;/i&gt; command → &lt;code&gt;inetmgr&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Expand &lt;i&gt;DefaultWeb&lt;span class="search-highlight"&gt;Sites&lt;/span&gt;&lt;/i&gt; or &lt;i&gt;Other Web &lt;span class="search-highlight"&gt;Sites&lt;/span&gt;&lt;/i&gt;, where you have created the virtual directory &lt;/li&gt;
&lt;li&gt;Right Click on the virtual directory &lt;/li&gt;
&lt;li&gt;Click on &lt;i&gt;Properties&lt;/i&gt; &lt;/li&gt;
&lt;/ol&gt;
The following virtual directory properties screen will come up, 
showing the Application Pool name which is assigned to the selected 
site.&lt;br /&gt;
&lt;img height="442" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg4.jpg" width="474" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 5: Virtual directory properties showing Application Pool name&lt;/div&gt;
If you want to check the list of all Application Pools in IIS, you have to expand the &lt;i&gt;Application Pool&lt;/i&gt; node on IIS Server. &lt;br /&gt;
&lt;img height="330" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg5.jpg" width="258" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 6: List of Application Pools&lt;/div&gt;
Now, each and every Application Pool should have the minimum of one 
Worker Process which takes care of the operation of the site which is 
associated with the Application Pool. Right-click on the Application 
Pool → go to the &lt;i&gt;Performance&lt;/i&gt; tab, check near the bottom of the tab, there is a &lt;i&gt;web garden&lt;/i&gt;
 section, and by default, the number of Worker Processes is 1. An 
Application Pool containing more than one Worker Process called a &lt;i&gt;Web Garden&lt;/i&gt;.&lt;br /&gt;
&lt;img height="435" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg6.jpg" width="461" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 7: Application Pool properties showing &lt;i&gt;Web garden&lt;/i&gt;&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;
&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="7"&gt;Creating and Assigning an Application Pool&lt;/a&gt; &lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Open the IIS Console, right-click on the &lt;i&gt;Application Pools&lt;/i&gt; folder, select &lt;i&gt;New&lt;/i&gt; 
&lt;img border="0" height="226" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/explor29.jpg" width="298" /&gt;&lt;br /&gt;


&lt;div class="Caption"&gt;
Fig. 8-1&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Give the Application Pool ID and click OK. 
&lt;img border="0" height="217" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/explor30.jpg" width="398" /&gt;&lt;br /&gt;


&lt;div class="Caption"&gt;
Fig. 8-2&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Now, right-click on the virtual directory and assign the newly created Application Pool to that virtual directory. 
&lt;img border="0" height="246" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/explor31.jpg" width="254" /&gt;&lt;br /&gt;


&lt;div class="Caption"&gt;
Fig. 8-3&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
Now, this web site will run independently, within &lt;i&gt;StateServerAppPool&lt;/i&gt;,
 so any problem related to other applications will not affect this 
application. This is the main advantage of creating a separate 
Application Pool.&lt;br /&gt;
&lt;h2&gt;


&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/h2&gt;
&lt;h2&gt;
&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="9"&gt;How to start?&lt;/a&gt;&lt;/b&gt;&lt;/h2&gt;
What I have said up to now give you a good idea of Worker Processes 
and Application Pools. You should have a clear understanding on these 
before going on to the next part. Now I will show you how to debug a 
site which is hosted on an IIS Server.&lt;br /&gt;
For the demonstration, I have created a web site called &lt;i&gt;SampleWebSite&lt;/i&gt; and hosted it on to my local IIS. Below is default page output.&lt;br /&gt;
&lt;img height="201" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg9.png" width="570" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 9: Sample web site&lt;/div&gt;
&lt;h2&gt;


&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/h2&gt;
&lt;h2&gt;
&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="10"&gt;Which process to attach to?&lt;/a&gt;&lt;/b&gt;&lt;/h2&gt;
Now, as I have already explained, the process name is &lt;i&gt;w3wp.exe&lt;/i&gt;, so we can check it from our Task Manager whether or not the Worker Process is running.&lt;br /&gt;
&lt;img height="410" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg11.jpg" width="445" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 10: Task Manager showing the running IIS process&lt;/div&gt;
Now we are going to attach to the process. In Visual Studio, go to &lt;i&gt;Debug&lt;/i&gt; → &lt;i&gt;Attach to Process&lt;/i&gt;&lt;br /&gt;
&lt;img height="306" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg10.jpg" width="554" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 11: Opening the &lt;i&gt;Attach to Process&lt;/i&gt; window&lt;/div&gt;
After clicking &lt;i&gt;Attach to Process&lt;/i&gt;, the following screen will come up&lt;br /&gt;
&lt;img height="382" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg12_11.jpg" width="575" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 12: &lt;i&gt;Attach to Process&lt;/i&gt; window, showing a single Worker Process running&lt;/div&gt;
Now we are able to see that the Worker Process is running, and we 
need to attach that process. Select the process and click on the &lt;i&gt;Attach&lt;/i&gt; button. After that, look at the two images below:&lt;br /&gt;
&lt;img height="98" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg7.gif" width="570" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 13-1: Process attached successfully&lt;/div&gt;
&lt;img height="106" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg8.gif" width="522" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 13-2: Process not attached&lt;/div&gt;
Did you notice the breakpoint symbol? If the Worker Process attached 
successfully, within the code, the breakpoint symbol should be a solid 
circle. Otherwise it will have a warning icon as shown. For a single 
Worker Process, this scenario is not common. However, when we have 
multiple Worker Processes running on IIS, then we can have some 
confusion. I will discuss the same in a later section.&lt;br /&gt;
Now if we click the &lt;i&gt;Debug&lt;/i&gt; button after successfully attaching to the process, execution will stop at the breakpoint. &lt;br /&gt;
Next, let's have a look at what to do if we have multiple Worker Processes running.&lt;br /&gt;
&lt;h2&gt;


&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/h2&gt;
&lt;h2&gt;
&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="11"&gt;How to attach to one of many running Worker Processes&lt;/a&gt;&lt;/b&gt;&lt;/h2&gt;
Now, when this scenario will come up? When we have multiple &lt;span class="search-highlight"&gt;sites&lt;/span&gt; hosted on IIS, and those &lt;span class="search-highlight"&gt;sites&lt;/span&gt; have their own Application Pool. Now, multiple Application Pools means multiple Worker Processes are running. &lt;br /&gt;
Here I have three Application Pools in my IIS. They are:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Default Application Pool &lt;/li&gt;
&lt;li&gt;Generic Application Pool &lt;/li&gt;
&lt;li&gt;State Server Application Pool &lt;/li&gt;
&lt;/ol&gt;
Now, my &lt;i&gt;SampleWebSite&lt;/i&gt; is associated with the &lt;i&gt;DefaultAppPool&lt;/i&gt;. Now, I want to attach the process to debug my &lt;i&gt;SampleWebSite&lt;/i&gt;. Follow the same steps as before. Open the &lt;i&gt;Process Attach&lt;/i&gt; window:&lt;br /&gt;
&lt;img height="218" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg9_1.gif" width="492" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 14: List of multiple Worker Process&lt;/div&gt;
Just have a look, there are three Worker Processes currently running,
 and you have to attach one of them. But, you do not know which Worker 
Process is the default Application Pool's. What you do is, you select 
any one of them at random, let's say the one with process ID = 4308&lt;code&gt;, &lt;/code&gt;and
 suppose it is not the Worker Process for the default Application Pool. 
So what will happen if you attach to a wrong process? Check the image 
below:&lt;br /&gt;
&lt;img height="138" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg10.gif" width="538" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 15: Breakpoint when the process is not attached correctly&lt;/div&gt;
&lt;h3&gt;


&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/h3&gt;
&lt;h3&gt;
&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="12"&gt;Getting a list of running Worker Processes&lt;/a&gt;&lt;/b&gt;&lt;/h3&gt;
Now what is the solution for the previous case? Here is a quick tip: &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;Start&lt;/i&gt; → Run command → &lt;i&gt;cmd&lt;/i&gt; &lt;/li&gt;
&lt;li&gt;Change directory to &lt;i&gt;\Windows\System32&lt;/i&gt; &lt;/li&gt;
&lt;li&gt;Run the command: &lt;code&gt;cscript iisapp.vbs&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;
and wait for the output. Wow! You get a list of running &lt;i&gt;Worker Process&lt;/i&gt;, &lt;i&gt;Process ID&lt;/i&gt; and &lt;i&gt;Application Pool Name&lt;/i&gt;!&lt;br /&gt;
&lt;img height="154" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg13.jpg" width="557" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 16: List of running Worker Processes with PID and Application Pool name&lt;/div&gt;
&lt;h3&gt;


&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/h3&gt;
&lt;h3&gt;
&lt;b&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="13"&gt;Attaching to the correct process&lt;/a&gt;&lt;/b&gt;&lt;/h3&gt;
From here you can easily identify the correct Application Pool name 
and its process ID. Now, return to Visual Studio → Attach Process. Now 
you know that the process ID for &lt;i&gt;Default Application Pool&lt;/i&gt; is &lt;code&gt;1772&lt;/code&gt;, so &lt;i&gt;Attach&lt;/i&gt; to that process. &lt;br /&gt;
&lt;img height="260" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg14_1.png" width="600" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 17: Attach the correct process for debugging&lt;/div&gt;
Now, enjoy debugging!&lt;br /&gt;
&lt;img height="98" src="http://www.codeproject.com/KB/aspnet/ProcessAttache/debugg15.jpg" width="531" /&gt;&lt;br /&gt;
&lt;div class="Caption"&gt;
Fig. 18: Breakpoint is ready&lt;/div&gt;
&lt;h2&gt;


&amp;nbsp;&lt;/h2&gt;
&lt;h2&gt;
&lt;a href="http://www.blogger.com/blogger.g?blogID=1537800241861894285" name="14"&gt;Summary&lt;/a&gt;&lt;/h2&gt;
Sometimes we need to debug our application which is hosted on IIS. 
For that, we need to attach the running Worker Process to the Visual 
Studio. If we have multiple Worker Processes running on the IIS server, 
we can identify the appropriate Worker Process by using the command &lt;code&gt;cscript iisapp.vbs&lt;/code&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-5612077304937729395?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8BsXa8o3ccr2uY4_b37kL7WcIiU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8BsXa8o3ccr2uY4_b37kL7WcIiU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8BsXa8o3ccr2uY4_b37kL7WcIiU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8BsXa8o3ccr2uY4_b37kL7WcIiU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/EKBVk5_ldTs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/5612077304937729395/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=5612077304937729395" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/5612077304937729395?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/5612077304937729395?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/EKBVk5_ldTs/aspnet-debugging-vs-iis-debugging.html" title="ASP.NET Debugging vs. IIS Debugging" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/aspnet-debugging-vs-iis-debugging.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEHQH04eip7ImA9WhdWE0Q.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-2461028430263994683</id><published>2011-09-07T16:37:00.000+05:30</published><updated>2011-09-07T16:37:11.332+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-07T16:37:11.332+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>How to raise client side (javascript)  or server side (code behind) messages in asp.net</title><content type="html">&lt;br /&gt;
Use below code to raise messages from javascript and code behind.&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: orange;"&gt;
&lt;u&gt;&lt;b&gt;.ASPX&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="RaisingMessages.aspx.cs"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits="RaisingMessages" %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;Validation&amp;lt;/title&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function ValidatePage() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var fName = document.getElementById("txtFirstName");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var lName = document.getElementById("txtLastName");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fName.value == "") {&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //client side alert message&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt; alert('First Name should not be empty');&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label ID="lblFirstName" runat="server" Text="First Name"&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox ID="txtFirstName" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label ID="lblLastName" runat="server" Text="Last Name"&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox ID="txtLastName" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td colspan="2"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnClientClick="return ValidatePage();" onclick="btnSubmit_Click" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: orange;"&gt;
&lt;u&gt;&lt;b&gt;.ASPX.CS&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;&lt;br /&gt;public partial class RaisingMessages : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void btnSubmit_Click(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (string.IsNullOrEmpty(txtLastName.Text.Trim()))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string script = "alert('Last Name should not be empty')";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type csType = GetType();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;// Server side alert message&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt; ScriptManager.RegisterStartupScript(Page, csType, "popuscript", script, true);&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-2461028430263994683?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TV8lja-qLExcyVcAv71KfobhTqE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TV8lja-qLExcyVcAv71KfobhTqE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TV8lja-qLExcyVcAv71KfobhTqE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TV8lja-qLExcyVcAv71KfobhTqE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/IDT7XFlWvNc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/2461028430263994683/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=2461028430263994683" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/2461028430263994683?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/2461028430263994683?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/IDT7XFlWvNc/how-to-raise-client-side-javascript-or.html" title="How to raise client side (javascript)  or server side (code behind) messages in asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/how-to-raise-client-side-javascript-or.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QNQnc7eyp7ImA9WhdWE0U.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-2771572474672141784</id><published>2011-09-07T13:37:00.001+05:30</published><updated>2011-09-07T14:19:53.903+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-07T14:19:53.903+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Sql Server" /><title>How to get the size of the Databases used in Sql server</title><content type="html">I was looking for an easy way to do this instead of opening up the 
property page of each database in management studio and looking at the 
size. First I found this store procedure &lt;b&gt;sp_spaceused&lt;/b&gt;.&lt;br /&gt;
 This is a very 
nice system store procedure that can give you the disk usage information
 of a database, a table or an index.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-dDYZw6U_oZg/Tmck1q1CVEI/AAAAAAAAB-0/uzKc7iwlho4/s1600/sql1.bmp" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-dDYZw6U_oZg/Tmck1q1CVEI/AAAAAAAAB-0/uzKc7iwlho4/s1600/sql1.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But when you use it to get database size you have to execute it 
within the database in question. It doesn’t take a database name as 
parameter. So it can be automated to run for each database using T-SQL. 
What I want is query that is able to list all database on the server 
together with the size they take up. So I wrote the following query to 
do that. It worked fine for me.&lt;br /&gt;
&lt;br /&gt;

&lt;blockquote style="background-color: #b4a7d6;"&gt;
&lt;code&gt;use master&lt;/code&gt;&lt;br /&gt;
declare @PageSize varchar(10)&lt;br /&gt;
select @PageSize=v.low/1024.0&lt;br /&gt;
from master..spt_values v&lt;br /&gt;
where v.number=1 and v.type='E'&lt;br /&gt;
select name as DatabaseName, convert(float,null) as Size&lt;br /&gt;
into #tem&lt;br /&gt;
From sysdatabases where dbid&amp;gt;4&lt;br /&gt;
declare @SQL varchar (8000)&lt;br /&gt;
set @SQL=''&lt;br /&gt;
while exists (select * from #tem where size is null)&lt;br /&gt;
begin&lt;br /&gt;
select @SQL='update #tem set size=(select 
round(sum(size)*'+@PageSize+'/1024,0) From 
'+quotename(databasename)+'.dbo.sysfiles) where 
databasename='''+databasename+''''&lt;br /&gt;
from #tem&lt;br /&gt;
where size is null&lt;br /&gt;
	exec (@SQL)&lt;br /&gt;
end &lt;br /&gt;
select * from #tem order by DatabaseName&lt;br /&gt;
drop table #tem&lt;/blockquote&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-rJHQ7jqVqrc/TmcmAk041CI/AAAAAAAAB-4/-uZ2TJ5RdcU/s1600/sql1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;Output&amp;nbsp;&amp;nbsp; &lt;img border="0" src="http://2.bp.blogspot.com/-rJHQ7jqVqrc/TmcmAk041CI/AAAAAAAAB-4/-uZ2TJ5RdcU/s1600/sql1.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;

The first select statement is to get how many kilobytes a data page 
has. SQL Server allocates disk space in the unit of data page. Currently
 each SQL server data page contains 8k bytes. The number of data pages 
allocated to each database file is recorded in the sysfiles system 
table. With this information on hand the script creates a temporary 
table #tem and update the temporary table with size information which is
 gathered by querying the sysfiles table.&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-2771572474672141784?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/W53D0YH54VF08MODsEfp9gS2Tbo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W53D0YH54VF08MODsEfp9gS2Tbo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/W53D0YH54VF08MODsEfp9gS2Tbo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W53D0YH54VF08MODsEfp9gS2Tbo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/H-nIlliWEX4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/2771572474672141784/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=2771572474672141784" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/2771572474672141784?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/2771572474672141784?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/H-nIlliWEX4/how-to-get-size-of-databases-used-in.html" title="How to get the size of the Databases used in Sql server" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-dDYZw6U_oZg/Tmck1q1CVEI/AAAAAAAAB-0/uzKc7iwlho4/s72-c/sql1.bmp" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/how-to-get-size-of-databases-used-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUHQHk6fCp7ImA9WhdWE0w.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-8788783625124050027</id><published>2011-09-06T18:17:00.000+05:30</published><updated>2011-09-06T18:17:11.714+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-06T18:17:11.714+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>How To: Protect From Injection Attacks in ASP.NET</title><content type="html">&lt;br /&gt;
&lt;h2 class="dtH1"&gt;
Summary&lt;/h2&gt;
This How To shows how you can validate input to protect your 
application from injection attacks. Performing input validation is 
essential because almost all application-level attacks contain malicious
 input. &lt;br /&gt;


You should validate all input, including form fields, query string 
parameters, and cookies to protect your application against malicious 
command injection. Assume all input to your Web application is 
malicious, and make sure that you use server validation for all sources 
of input. Use client-side validation to reduce round trips to the server
 and to improve the user experience, but do not rely on it because it is
 easily bypassed. &lt;br /&gt;


To validate input, define acceptable input for each application input
 field. A proven practice is to constrain input for length, range, 
format, and type. Use the list of acceptable characters to define valid 
input, instead of the list of unacceptable characters. Using the list of
 unacceptable characters is impractical because it is very difficult to 
anticipate all possible variations of bad input.&lt;br /&gt;


When you need to accept a range of HTML characters, make sure that 
you HTML-encode the data to make it safe prior to displaying it as 
output.&lt;br /&gt;


&lt;h2 class="dtH1"&gt;
Contents&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Objectives&lt;/li&gt;
&lt;li&gt;Overview&lt;/li&gt;
&lt;li&gt;Summary of Steps&lt;/li&gt;
&lt;li&gt;Step 1. Use ASP.NET Request Validation&lt;/li&gt;
&lt;li&gt;Step 2. Constrain Input&lt;/li&gt;
&lt;li&gt;Step 3. Encode Unsafe Output&lt;/li&gt;
&lt;li&gt;Step 4. Use Command Parameters for SQL Queries&lt;/li&gt;
&lt;li&gt;Step 5. Verify that ASP.NET Errors Are Not Returned to the Client&lt;/li&gt;
&lt;li&gt;
Additional Resources&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 class="dtH1"&gt;
Objectives&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Constrain input for length, range, format, and type.&lt;/li&gt;
&lt;li&gt;Apply ASP.NET request validation during development to identify injection attacks.&lt;/li&gt;
&lt;li&gt;Constrain input by using ASP.NET validator controls.&lt;/li&gt;
&lt;li&gt;Encode unsafe output.&lt;/li&gt;
&lt;li&gt;Help prevent SQL injection by using command parameters.&lt;/li&gt;
&lt;li&gt;Prevent detailed error information from returning to the client.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 class="dtH1"&gt;
Overview&lt;/h2&gt;
You need to validate all untrusted input to your application. You 
should assume that any input from users is malicious. User input to your
 Web application includes form fields, query strings, client-side 
cookies, and browser environment values such as user agent strings and 
IP addresses. &lt;br /&gt;


Weak input validation is a common vulnerability that could allow your
 application to be exploited by a number of injection attacks. The 
following are common types of attacks that exploit weak or missing input
 validation:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SQL injection. &lt;/strong&gt;If you generate dynamic SQL queries
 based on user input, an attacker could inject malicious SQL commands 
that can be executed by the database.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cross-site scripting.&lt;/strong&gt; Cross-site scripting (XSS) 
attacks exploit vulnerabilities in Web page validation by injecting 
client-side script code. This code is subsequently sent to an 
unsuspecting user's computer and executed on the browser. Because the 
browser downloads the script code from a trusted site, the browser has 
no way of determining whether the code is legitimate. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Unauthorized file access.&lt;/strong&gt; If your code accepts 
input from a caller, a malicious user could potentially manipulate your 
code's file operations, such as accessing a file they should not access 
or exploiting your code by injecting bad data.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote class="dtBlock"&gt;

&lt;strong&gt;Note&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Injection attacks work over HTTP and HTTPS Secure Socket Layer (SSL) connections. Encryption provides no defense.&lt;/blockquote&gt;
The general approach for input validation is summarized here. You 
should apply this approach to any input that comes from the network, 
such as text boxes and other forms field input, query string parameters,
 cookies, server variables, and Web method parameters. Note that the 
strategy is to first allow only good input and then deny bad input. This
 is because you can easily define good input for your application, but 
you cannot realistically anticipate the format for all malicious input. &lt;br /&gt;


Check for valid input as follows:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Constrain: &lt;/strong&gt;Check for known good data by validating
 the type, length, format, and range. To constrain input from server 
controls, use the ASP.NET validator controls. To constrain input from 
other sources, use regular expressions and custom validation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reject:&lt;/strong&gt; Check for any known bad data and reject bad input.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sanitize:&lt;/strong&gt; Sometimes you also need to sanitize 
input and make potentially malicious input safe. For example, if your 
application supports free-format input fields, such as comment fields, 
you might want to permit certain safe HTML elements, such as &amp;lt;&lt;strong&gt;b&lt;/strong&gt;&amp;gt; and &amp;lt;&lt;strong&gt;i&lt;/strong&gt;&amp;gt;, and eliminate any other HTML elements.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 class="dtH1"&gt;
Summary of Steps&lt;/h2&gt;
To protect your ASP.NET application from injection attacks, perform the following steps:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Step 1. Use ASP.NET request validation. &lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Step 2. Constrain input. &lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Step 3. Encode unsafe output. &lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Step 4. Use command parameters for SQL queries. &lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Step 5. Verify that ASP.NET errors are not returned to the client. &lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
The next sections describe each of these.&lt;br /&gt;


&lt;h2 class="dtH1"&gt;
Step 1. Use ASP.NET Request Validation&lt;/h2&gt;
By default, ASP.NET versions 1.1 and 2.0 request validation detects 
any HTML elements and reserved characters in data posted to the server. 
This helps prevent users from inserting script into your application. 
Request validation checks all input data against a hard-coded list of 
potentially dangerous values. If a match occurs, it throws an exception 
of type &lt;strong&gt;HttpRequestValidationException&lt;/strong&gt;.&lt;br /&gt;


You can disable request validation in your Web.config application configuration file by adding a &amp;lt;&lt;strong&gt;pages&lt;/strong&gt;&amp;gt; element with &lt;strong&gt;validateRequest="false"&lt;/strong&gt; or on an individual page by setting &lt;strong&gt;ValidateRequest="false"&lt;/strong&gt; on the &lt;strong&gt;@ Pages&lt;/strong&gt; element. &lt;br /&gt;


If you need to disable request validation, you should disable it only
 on the affected page. An example of this is when you have a page with a
 free-format text field that accepts HTML-formatted input.&lt;br /&gt;


&lt;h3 class="dtH1"&gt;
Confirm that ASP.NET Request Validation Is Enabled in Machine.config&lt;/h3&gt;
Request validation is enabled by ASP.NET by default. You can see the 
following default setting in the Machine.config.comments file.&lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;pages validateRequest="true" ... /&amp;gt;
  &lt;/pre&gt;
Confirm that you have not disabled request validation by overriding 
the default settings in your server's Machine.config file or your 
application's Web.config file. &lt;br /&gt;


&lt;h3 class="dtH1"&gt;
Test ASP.NET Request Validation&lt;/h3&gt;
You can test the effects of request validation. To do this, create an ASP.NET page that disables request validation by setting &lt;strong&gt;ValidateRequest="false"&lt;/strong&gt;, as follows.&lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;%@ Language="C#" ValidateRequest="false" %&amp;gt;
&amp;lt;html&amp;gt;
 &amp;lt;script runat="server"&amp;gt;
  void btnSubmit_Click(Object sender, EventArgs e)
  {
    // If ValidateRequest is false, then 'hello' is displayed
    // If ValidateRequest is true, then ASP.NET returns an exception
    Response.Write(txtString.Text);
  }
 &amp;lt;/script&amp;gt;
 &amp;lt;body&amp;gt;
  &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;asp:TextBox id="txtString" runat="server" 
                 Text="&amp;lt;script&amp;gt;alert('hello');&amp;lt;/script&amp;gt;" /&amp;gt;
    &amp;lt;asp:Button id="btnSubmit" runat="server" OnClick="btnSubmit_Click" 
                 Text="Submit" /&amp;gt;
  &amp;lt;/form&amp;gt;
 &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
  &lt;/pre&gt;
When you run the page, "Hello" is displayed in a message box because the script in &lt;strong&gt;txtString&lt;/strong&gt; is passed through and rendered as client-side script in your browser.&lt;br /&gt;


If you set &lt;strong&gt;ValidateRequest="true" &lt;/strong&gt;or remove the &lt;strong&gt;ValidateRequest&lt;/strong&gt; page attribute, ASP.NET request validation rejects the script input and produces an error similar to the following.&lt;br /&gt;


&lt;pre class="code"&gt;A potentially dangerous Request.Form value was detected from the client (txtString="&amp;lt;script&amp;gt;alert('hello...").
  &lt;/pre&gt;
&lt;blockquote class="dtBlock"&gt;

&lt;strong&gt;Note&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Do not rely on ASP.NET request validation. Treat
 it as an extra precautionary measure in addition to your own input 
validation.&lt;/blockquote&gt;
&lt;h2 class="dtH1"&gt;
Step 2. Constrain Input&lt;/h2&gt;
To constrain input, follow these guidelines:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use server-side input validation.&lt;/strong&gt; Do not rely on 
client-side validation because it is easily bypassed. Use client-side 
validation in addition to server-side validation to reduce round trips 
to the server and to improve the user experience.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validate length, range, format and type.&lt;/strong&gt; Make sure that any input meets your guidelines for known good input.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use strong data typing. &lt;/strong&gt;Assign numeric values to numeric data types such as &lt;strong&gt;Integer&lt;/strong&gt; or &lt;strong&gt;Double&lt;/strong&gt;. Assign string values to string data types. Assign dates to the &lt;strong&gt;DateTime&lt;/strong&gt; data type.&lt;/li&gt;
&lt;/ul&gt;
For Web form applications that obtain input through server controls, 
use the ASP.NET validator controls to constrain the input. For other 
sources of input data, such as query strings, cookies, and HTTP headers,
 constrain input by using the &lt;strong&gt;Regex&lt;/strong&gt; class from the &lt;strong&gt;System.Text.RegularExpressions&lt;/strong&gt; namespace.&lt;br /&gt;


&lt;h3 class="dtH1"&gt;
Explicitly Check Input from Form Fields&lt;/h3&gt;
To constrain form field input received through server controls, you can use the following ASP.NET validator controls:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;RegularExpressionValidator.&lt;/strong&gt; Use this control to constrain text input.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RangeValidator.&lt;/strong&gt; Use this control to check the ranges of numeric, currency, date, and string input.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CustomValidator.&lt;/strong&gt; Use this control for custom validation, such as ensuring that a date is in the future or in the past.&lt;/li&gt;
&lt;/ul&gt;
To validate form field input received through HTML input controls, perform validation in server-side code and use the &lt;strong&gt;Regex&lt;/strong&gt; class to help constrain text input. The following sections describe how to constrain a variety of common input types.&lt;br /&gt;


&lt;h4 class="dtH1"&gt;
Validating Text Fields &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;To validate text fields, such as names, addresses, and tax identification numbers, use regular expressions to do the following:&lt;/li&gt;
&lt;li&gt;Constrain the acceptable range of input characters. &lt;/li&gt;
&lt;li&gt;Apply formatting rules. For example, pattern-based fields, such as 
tax identification numbers, ZIP Codes, or postal codes, require specific
 patterns of input characters. &lt;/li&gt;
&lt;li&gt;Check lengths.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 class="dtH1"&gt;
Using a RegularExpressionValidator&lt;/h4&gt;
To use a &lt;strong&gt;RegularExpressionValidator&lt;/strong&gt;, set the &lt;strong&gt;ControlToValidate&lt;/strong&gt;, &lt;strong&gt;ValidationExpression&lt;/strong&gt;, and &lt;strong&gt;ErrorMessage &lt;/strong&gt;properties to appropriate values as shown in the following example.&lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;form id="WebForm" method="post" runat="server"&amp;gt;
  &amp;lt;asp:TextBox id="txtName" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;
  &amp;lt;asp:RegularExpressionValidator id="nameRegex" runat="server" 
        ControlToValidate="txtName" 
        ValidationExpression="^[a-zA-Z'.\s]{1,40}$" 
        ErrorMessage="Invalid name"&amp;gt;
  &amp;lt;/asp:regularexpressionvalidator&amp;gt;
&amp;lt;/form&amp;gt;
  &lt;/pre&gt;
The regular expression used in the preceding code example limits an 
input name field to alphabetic characters (lowercase and uppercase), 
space characters, the single apostrophe for names such as O'Dell, and 
the period. In addition, the field length is constrained to 40 
characters.&lt;br /&gt;


&lt;blockquote class="dtBlock"&gt;

&lt;strong&gt;Note&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;The &lt;strong&gt;RegularExpressionValidator&lt;/strong&gt; 
control automatically adds a caret (^) and dollar sign ($) as delimiters
 to the beginning and end of expressions if you have not added them 
yourself. You should add them to all of your regular expressions as good
 practice. Enclosing the expression in the delimiters ensures that the 
expression consists of the desired content and nothing else.&lt;/blockquote&gt;
&lt;h4 class="dtH1"&gt;
Using the Regex Class&lt;/h4&gt;
If you are not using server controls (which means you cannot use the 
validator controls), or you need to validate input from sources other 
than form fields (such as from query string parameters or cookies), you 
can use a &lt;strong&gt;Regex&lt;/strong&gt; class.&lt;br /&gt;


&lt;strong&gt;To use the Regex class&lt;/strong&gt;

&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Add a &lt;strong&gt;using&lt;/strong&gt; statement to reference the&lt;strong&gt; System.Text.RegularExpressions&lt;/strong&gt; namespace. &lt;/li&gt;
&lt;li&gt;Ensure that the regular expression is contained in the ^ and $ anchor characters (beginning of string, end of string).&lt;/li&gt;
&lt;li&gt;Call the &lt;strong&gt;IsMatch&lt;/strong&gt; method of the &lt;strong&gt;Regex&lt;/strong&gt; class, as shown in the following code example.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class="code"&gt;// Instance method:
Regex reg = new Regex(@"^[a-zA-Z'.\s]{1,40}$");
Response.Write(reg.IsMatch(txtName.Text));

// Static method:
if (!Regex.IsMatch(txtName.Text,@"^[a-zA-Z'.\s]{1,40}$")) 
{
  // Name does not match expression
}
  &lt;/pre&gt;
If you cannot cache your regular expression for frequent use, you should use the static &lt;strong&gt;IsMatch&lt;/strong&gt; method where possible for performance reasons, to avoid unnecessary object creation.&lt;br /&gt;


&lt;h4 class="dtH1"&gt;
Validating Numeric Fields&lt;/h4&gt;
In most cases, numeric fields should be checked for type and range. 
To validate the type and range of a numeric input field that uses a 
server control, you can use a &lt;strong&gt;RangeValidator&lt;/strong&gt; control. The &lt;strong&gt;RangeValidator&lt;/strong&gt; supports currency, date, integer, double, and string data types. &lt;br /&gt;


To use a &lt;strong&gt;RangeValidator&lt;/strong&gt;, set the &lt;strong&gt;ControlToValidate&lt;/strong&gt;, &lt;strong&gt;Type&lt;/strong&gt;, &lt;strong&gt;MinimumValue&lt;/strong&gt;, &lt;strong&gt;MaximumValue&lt;/strong&gt;, and &lt;strong&gt;ErrorMessage&lt;/strong&gt; properties to appropriate values as shown in the following example.&lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;asp:RangeValidator 
       ID="RangeValidator1" 
       Runat="server" 
       ErrorMessage="Invalid range. Number must be between 0 and 255."
       ControlToValidate="rangeInput" 
       MaximumValue="255" 
       MinimumValue="0" Type="Integer" /&amp;gt;
  &lt;/pre&gt;
If you are not using a server control, you can validate a numeric 
range by converting the input value to an integer and then performing a 
range check. For example, to validate that an integer is valid, convert 
the input value to a variable of type &lt;strong&gt;System.Int32&lt;/strong&gt; by using the new &lt;strong&gt;Int32.TryParse&lt;/strong&gt; method (introduced in the Microsoft .NET Framework version 2.0). This method returns &lt;strong&gt;false&lt;/strong&gt; if the type conversion fails.&lt;br /&gt;


&lt;pre class="code"&gt;Int32 i;
if (Int32.TryParse(txtInput.Text, out i) == false)
{
  // Conversion failed
}
  &lt;/pre&gt;
If you are using an earlier version of the .NET Framework, you can use &lt;strong&gt;Int32.Parse&lt;/strong&gt; or&lt;strong&gt; Convert.ToInt32 &lt;/strong&gt;inside a try/catch block and handle any exceptions of type &lt;strong&gt;FormatException&lt;/strong&gt; that are thrown if the input value is not the correct type.&lt;br /&gt;


The following code shows how to perform a type and range check for an integer entered through an HTML text input control. &lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;%@ Page Language="C#" %&amp;gt;

&amp;lt;script runat="server"&amp;gt;

  void Page_Load(object sender, EventArgs e)
  {
    if (Request.RequestType == "POST")
    {
      int i;
      if (Int32.TryParse(Request.Form["integerTxt"], out i) == true)
      {
        // TryParse returns true if the conversion succeeds
        if ((0 &amp;lt;= i &amp;amp;&amp;amp; i &amp;lt;= 255) == true)
        {
          Response.Write("Input data is valid.");
        }
        else
          Response.Write("Input data is out of range");
      }
      else
        Response.Write("Input data is not an integer");
    }
  }
   
&amp;lt;/script&amp;gt;

&amp;lt;html&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;form id="form1" action="NumericInput.aspx" method="post"&amp;gt;
      &amp;lt;div&amp;gt;
        Enter an integer between 0 and 255:
        &amp;lt;input name="integerTxt" type="text" /&amp;gt;
        &amp;lt;input name="Submit" type="submit" value="submit" /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
  &lt;/pre&gt;
&lt;h4 class="dtH1"&gt;
Validating Date Fields&lt;/h4&gt;
You need to validate that date fields are of the correct type. In 
most cases, you also need to check them for range, for example to 
validate that they are in the future or past. If you use a server 
control to capture an input date, and if you also need to validate that a
 date falls within a specific range, you can use a &lt;strong&gt;RangeValidator&lt;/strong&gt; control with its &lt;strong&gt;Type&lt;/strong&gt; field set to &lt;strong&gt;Date&lt;/strong&gt;.
 This control lets you specify a range by using constant date values. If
 you need to validate a date range based on today's date, for example to
 validate that a date is in the future or the past, you can use a &lt;strong&gt;CustomValidator&lt;/strong&gt; control.&lt;br /&gt;


To use a &lt;strong&gt;CustomValidator&lt;/strong&gt; control to validate a date, set the &lt;strong&gt;ControlToValidate&lt;/strong&gt; and &lt;strong&gt;ErrorMessage&lt;/strong&gt; properties and the &lt;strong&gt;OnServerValidate&lt;/strong&gt; event to point to a custom method containing your validation logic. The following sample .aspx page code shows this approach.&lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;%@ Page Language="C#" %&amp;gt;

&amp;lt;script runat="server"&amp;gt;

 void ValidateDateInFuture(object source, ServerValidateEventArgs args)
 {
   DateTime dt;

   // Check for valid date and that the date is in the future
   if ((DateTime.TryParse(args.Value, out dt) == false) || 
       (dt &amp;lt;= DateTime.Today))
   {
     args.IsValid = false;
   }
 }

&amp;lt;/script&amp;gt;

&amp;lt;html&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;asp:Label ID="Label1" Runat="server" 
                   Text="Future Date:"&amp;gt;&amp;lt;/asp:Label&amp;gt;
        &amp;lt;asp:TextBox ID="futureDatetxt" Runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;
        &amp;lt;asp:CustomValidator 
              ID="CustomValidator1" Runat="server" 
              ErrorMessage="Invalid date. Enter a date in the future."
              ControlToValidate="futureDatetxt"  
              OnServerValidate="ValidateDateInFuture"&amp;gt;
        &amp;lt;/asp:CustomValidator&amp;gt;
        &amp;lt;br /&amp;gt;
        &amp;lt;asp:Button ID="submitBtn" Runat="server" Text="Submit"  /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
  &lt;/pre&gt;
&lt;blockquote class="dtBlock"&gt;

&lt;strong&gt;Note&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;The preceding code uses &lt;strong&gt;DateTime.TryParse&lt;/strong&gt;, which is new to .NET Framework 2.0.&lt;/blockquote&gt;
&lt;h3 class="dtH1"&gt;
Sanitizing Free-Text Fields&lt;/h3&gt;
To &lt;em&gt;sanitize&lt;/em&gt; input, you make untrusted input safe by 
preventing it from being treated as code. For example, if your 
application handles user input that it cannot constrain or reads data 
from a shared database, you might need to sanitize the data or make the 
output safe when you write it on your page. Sanitize data prior to 
output by using &lt;strong&gt;HttpUtility.HtmlEncode&lt;/strong&gt;. &lt;br /&gt;


&lt;h3 class="dtH1"&gt;
Allowing Restricted HTML Input&lt;/h3&gt;
If your application needs to accept a range of HTML elementsfor 
example through a rich text input field such as a comments fieldturn 
off ASP.NET request validation and create a filter that allows only the 
HTML elements that you want your application to accept. A common 
practice is to restrict formatting to safe HTML elements such as &amp;lt;&lt;strong&gt;b&lt;/strong&gt;&amp;gt; (bold) and &amp;lt;&lt;strong&gt;i&lt;/strong&gt;&amp;gt;
 (italic). Before writing the data, HTML-encode it. This makes any 
malicious script safe by causing it to be handled as text, not as 
executable code. &lt;br /&gt;


&lt;strong&gt;To allow restricted HTML input&lt;/strong&gt;

&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Disable ASP.NET request validation by the adding the &lt;strong&gt;ValidateRequest="false"&lt;/strong&gt; attribute to the &lt;strong&gt;@ Page&lt;/strong&gt; directive. &lt;/li&gt;
&lt;li&gt;Encode the string input with the &lt;strong&gt;HtmlEncode&lt;/strong&gt; method.&lt;/li&gt;
&lt;li&gt;Use a &lt;strong&gt;StringBuilder&lt;/strong&gt; and call its Replace method to selectively remove the encoding on the HTML elements that you want to permit. &lt;/li&gt;
&lt;/ol&gt;
The following .aspx page code shows this approach. The page disables ASP.NET request validation by setting &lt;strong&gt;ValidateRequest="false"&lt;/strong&gt;. It HTML-encodes the input and selectively allows the &amp;lt;&lt;strong&gt;b&lt;/strong&gt;&amp;gt; and &amp;lt;&lt;strong&gt;i&lt;/strong&gt;&amp;gt; HTML elements to support simple text formatting. &lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;%@ Page Language="C#" ValidateRequest="false"%&amp;gt;

&amp;lt;script runat="server"&amp;gt;

  void submitBtn_Click(object sender, EventArgs e)
  {
    // Encode the string input
    StringBuilder sb = new StringBuilder(
                            HttpUtility.HtmlEncode(htmlInputTxt.Text));
    // Selectively allow  and &amp;lt;i&amp;gt;
    sb.Replace("&amp;amp;lt;b&amp;amp;gt;", "&amp;lt;b&amp;gt;");
    sb.Replace("&amp;amp;lt;/b&amp;amp;gt;", "");
    sb.Replace("&amp;amp;lt;i&amp;amp;gt;", "&amp;lt;i&amp;gt;");
    sb.Replace("&amp;amp;lt;/i&amp;amp;gt;", "");
    Response.Write(sb.ToString());
  }
&amp;lt;/script&amp;gt;

&amp;lt;html&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;asp:TextBox ID="htmlInputTxt" Runat="server" 
                     TextMode="MultiLine" Width="318px"
                     Height="168px"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;
        &amp;lt;asp:Button ID="submitBtn" Runat="server" 
                     Text="Submit" OnClick="submitBtn_Click" /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
  &lt;/pre&gt;
&lt;h3 class="dtH1"&gt;
Validate Query String Values&lt;/h3&gt;
Validate query string values for length, range, format, and type. You
 usually do this by using a combination of regular expressions to:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Constrain the input values.&lt;/li&gt;
&lt;li&gt;Set explicit range checks.&lt;/li&gt;
&lt;li&gt;Specify the explicit type checks performed by converting the input 
value to its equivalent .NET Framework type and handling any ensuing 
conversion errors.&lt;/li&gt;
&lt;/ul&gt;
The following code example shows how to use the &lt;strong&gt;Regex&lt;/strong&gt; class to validate a name string passed on a query string. &lt;br /&gt;


&lt;pre class="code"&gt;void Page_Load(object sender, EventArgs e)
{
  if (!System.Text.RegularExpressions.Regex.IsMatch(
       Request.QueryString["Name"], @"^[a-zA-Z'.\s]{1,40}$"))
    Response.Write("Invalid name parameter");
  else
    Response.Write("Name is " + Request.QueryString["Name"]);
}
  &lt;/pre&gt;
&lt;h3 class="dtH1"&gt;
Validate Cookie Values&lt;/h3&gt;
Values maintained in cookies, such as query string parameters, can 
easily be manipulated by a client. Validate cookie values in the same 
way as you would for query string parameters. Validate them for length, 
range, format, and type.&lt;br /&gt;


&lt;h3 class="dtH1"&gt;
Validate File and URL Paths&lt;/h3&gt;
If your application has to accept input file names, file paths, or 
URL paths, you need to validate that the path is in the correct format 
and that it points to a valid location within the context of your 
application. Failure to do this can result in attackers persuading your 
application into accessing arbitrary files and resources. &lt;br /&gt;


&lt;h4 class="dtH1"&gt;
Validating File Paths&lt;/h4&gt;
To prevent a malicious user manipulating your code's file operations,
 avoid writing code that accepts user-supplied file or path input. For 
example:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;If you must accept file names as input, use the full name of the file by using &lt;strong&gt;System.IO.Path.GetFileName&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;If you must accept file paths as input, use the full file path by using &lt;strong&gt;System.IO.Path.GetFullPath&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 class="dtH1"&gt;
Using MapPath to Prevent Cross Application Mapping&lt;/h4&gt;
If you use &lt;strong&gt;MapPath&lt;/strong&gt; to map a supplied virtual path to a physical path on the server, use the overload of &lt;strong&gt;Request.MapPath&lt;/strong&gt; that accepts a &lt;strong&gt;bool&lt;/strong&gt; parameter so that you can prevent cross-application mapping. The following code example shows this technique.&lt;br /&gt;


&lt;pre class="code"&gt;try
{
  string mappedPath = Request.MapPath( inputPath.Text, 
                                       Request.ApplicationPath, false);
}
catch (HttpException)
{
  // Cross-application mapping attempted
}
  &lt;/pre&gt;
The final &lt;strong&gt;false&lt;/strong&gt; parameter prevents cross-application mapping. This means that a user cannot successfully supply a path that contains &lt;strong&gt;".."&lt;/strong&gt; to traverse outside of your application's virtual directory hierarchy. Any attempt to do this results in an exception of type &lt;strong&gt;HttpException&lt;/strong&gt;.&lt;br /&gt;


If you use server controls, you can use the &lt;strong&gt;Control.MapPathSecure&lt;/strong&gt; method to retrieve the physical path to which the virtual path is mapped. &lt;strong&gt;Control.MapPathSecure&lt;/strong&gt; uses code access security and throws an &lt;strong&gt;HttpException&lt;/strong&gt; if the server control does not have permissions to read the resulting mapped file. For more information, see &lt;strong&gt;Control.MapPathSecure&lt;/strong&gt; in the .NET Framework SDK documentation.&lt;br /&gt;


&lt;h4 class="dtH1"&gt;
Using Code Access Security to Restrict File I/O&lt;/h4&gt;
An administrator can restrict an application's file I/O to its own 
virtual directory hierarchy by configuring the application to run with 
Medium trust. In this event, .NET code access security ensures that no 
file access is permitted outside of the application's virtual directory 
hierarchy.&lt;br /&gt;


You configure an application to run with Medium trust by setting the &amp;lt;&lt;strong&gt;trust&lt;/strong&gt;&amp;gt; element in Web.config or Machine.config.&lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;trust level="Medium" /&amp;gt;
  &lt;/pre&gt;
&lt;h4 class="dtH1"&gt;
Validating URLs&lt;/h4&gt;
You can filter for a valid URL format using a regular expression, such as the following.&lt;br /&gt;


&lt;pre class="code"&gt;^(?:http|https|ftp)://[a-zA-Z0-9\.\-]+(?:\:\d{1,5})?(?:[A-Za-z0-9\.\;\:\@\&amp;amp;\=\+\$\,\?/]|%u[0-9A-Fa-f]{4}|%[0-9A-Fa-f]{2})*$
  &lt;/pre&gt;
This constrains the input, but it does not validate whether the URL 
is valid in terms of the application boundaries. You should check 
whether the target is valid in the context of your application. For 
example, does it point to an authorized server that you expect your 
application to communicate with?&lt;br /&gt;


&lt;h2 class="dtH1"&gt;
Step 3. Encode Unsafe Output&lt;/h2&gt;
If you write text output to a Web page, encode it using &lt;strong&gt;HttpUtility.HtmlEncode&lt;/strong&gt;. Do this if the text came from user input, a database, or a local file. &lt;br /&gt;


Similarly, if you write URLs that might contain unsafe characters 
because they have been constructed from input data or data from a shared
 database, use &lt;strong&gt;HttpUtilty.UrlEncode&lt;/strong&gt; to make them safe. &lt;br /&gt;


Avoid the mistake of encoding the data early. Make sure you encode at
 the last possible opportunity before the data is displayed to the 
client. &lt;br /&gt;


&lt;h3 class="dtH1"&gt;
Use HtmlEncode to Encode Unsafe Output&lt;/h3&gt;
The &lt;strong&gt;HtmlEncode&lt;/strong&gt; method replaces characters that have 
special meaning in HTML to HTML variables that represent those 
characters. For example, &amp;lt; is replaced with &lt;strong&gt;&amp;amp;lt;&lt;/strong&gt; and &lt;strong&gt;"&lt;/strong&gt; is replaced with &lt;strong&gt;&amp;amp;quot;&lt;/strong&gt;.
 Encoded data does not cause the browser to execute code. Instead, the 
data is rendered as harmless text, and the tags are not interpreted as 
HTML.&lt;br /&gt;


To illustrate the use of &lt;strong&gt;HtmlEncode&lt;/strong&gt;, the following page accepts input from the user and allows potentially unsafe HTML characters by setting &lt;strong&gt;ValidateRequest="false"&lt;/strong&gt;. Before writing the input back to the user, the code calls &lt;strong&gt;HttpUtility.HtmlEncode&lt;/strong&gt; on the supplied input text. This renders any potentially unsafe HTML as harmless text. &lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;%@ Page Language="C#" ValidateRequest="false" %&amp;gt;

&amp;lt;script runat="server"&amp;gt;
  void submitBtn_Click(object sender, EventArgs e)
  {
      Response.Write(HttpUtility.HtmlEncode(inputTxt.Text));
  }
&amp;lt;/script&amp;gt;

&amp;lt;html xmlns="http://www.w3.org/1999/xhtml" &amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;asp:TextBox ID="inputTxt" Runat="server" 
             TextMode="MultiLine" Width="382px" Height="152px"&amp;gt;
        &amp;lt;/asp:TextBox&amp;gt;
        &amp;lt;asp:Button ID="submitBtn" Runat="server" Text="Submit" 
                    OnClick="submitBtn_Click" /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
  &lt;/pre&gt;
To see the effect of the HTML encoding, place the preceding page in a
 virtual directory, browse to it, enter some HTML code in the input text
 box, and click &lt;strong&gt;Submit&lt;/strong&gt;. For example, the following input is rendered as text.&lt;br /&gt;


&lt;pre class="code"&gt;Run script and say hello &amp;lt;script&amp;gt;alert('hello');&amp;lt;/script&amp;gt;
  &lt;/pre&gt;
It produces the following safe output.&lt;br /&gt;


&lt;pre class="code"&gt;Run script and say hello &amp;lt;script&amp;gt;alert('hello');&amp;lt;/script&amp;gt;
  &lt;/pre&gt;
If you remove the call to &lt;strong&gt;HtmlEncode&lt;/strong&gt; and simply 
write back the input, the browser executes the script and displays a 
message box. Malicious script could pose a significant threat. &lt;br /&gt;


&lt;h3 class="dtH1"&gt;
Use UrlEncode to Encode Unsafe URLs&lt;/h3&gt;
If you need to write URLs that are based on input that you do not fully trust, use &lt;strong&gt;HttpUtility.UrlEncode&lt;/strong&gt; to encode the URL string.&lt;br /&gt;


&lt;pre class="code"&gt;HttpUtility.UrlEncode( urlString );
  &lt;/pre&gt;
&lt;h2 class="dtH1"&gt;
Step 4. Use Command Parameters for SQL Queries&lt;/h2&gt;
To help prevent SQL injection, use command parameters for SQL queries. The &lt;strong&gt;Parameters&lt;/strong&gt; collection provides type checking and length validation. If you use the &lt;strong&gt;Parameters&lt;/strong&gt;
 collection, input is treated as a literal value and SQL does not treat 
it as executable code. An additional benefit of using the &lt;strong&gt;Parameters&lt;/strong&gt; collection is that you can enforce type and length checks. Values outside of the range trigger an exception.&lt;br /&gt;


&lt;h3 class="dtH1"&gt;
Use Parameters Collection When You Call a Stored Procedure&lt;/h3&gt;
The following code fragment illustrates the use of the &lt;strong&gt;Parameters&lt;/strong&gt; collection when calling a stored procedure.&lt;br /&gt;


&lt;pre class="code"&gt;SqlDataAdapter myCommand = new SqlDataAdapter("AuthorLogin", 
                                     myConnection);
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlParameter parm = myCommand.SelectCommand.Parameters.Add(
                                       "@LoginId", SqlDbType.VarChar, 11);
parm.Value = Login.Text;
  &lt;/pre&gt;
&lt;h3 class="dtH1"&gt;
Use Parameters Collection When Building Your SQL Statements&lt;/h3&gt;
If you cannot use stored procedures, you can still use parameters, as shown in the following code fragment.&lt;br /&gt;


&lt;pre class="code"&gt;SqlDataAdapter myCommand = new SqlDataAdapter(
"SELECT au_lname, au_fname FROM Authors WHERE au_id = @au_id", myConnection);
SQLParameter parm = myCommand.SelectCommand.Parameters.Add(
                           "@au_id" ,SqlDbType.VarChar, 11);
Parm.Value = Login.Text;
  &lt;/pre&gt;
For more information about how to prevent SQL injection,&lt;br /&gt;
 see &lt;a href="http://msdn.microsoft.com/en-us/library/ms998271.aspx"&gt;How To: Protect From SQL Injection in ASP.NET&lt;/a&gt;.&lt;br /&gt;


&lt;h2 class="dtH1"&gt;
Step 5. Verify that ASP.NET Errors Are Not Returned to the Client&lt;/h2&gt;
You can use the &amp;lt;&lt;strong&gt;customErrors&lt;/strong&gt;&amp;gt; element to 
configure custom, generic error messages that should be returned to the 
client in the event of an application exception condition.&lt;br /&gt;


Make sure that the &lt;strong&gt;mode&lt;/strong&gt; attribute is set to &lt;strong&gt;"remoteOnly"&lt;/strong&gt; in the web.config file as shown in the following example.&lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;customErrors mode="remoteOnly" /&amp;gt;
  &lt;/pre&gt;
After installing an ASP.NET application, you can configure the 
setting to point to your custom error page as shown in the following 
example.&lt;br /&gt;


&lt;pre class="code"&gt;&amp;lt;customErrors mode="On" defaultRedirect="YourErrorPage.htm" /&amp;gt;
  &lt;/pre&gt;
&lt;h2 class="dtH1"&gt;
Additional Resources&lt;/h2&gt;
For more information about how to protect your application from injection attacks, see the following documents:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998267.aspx"&gt;How To: Use Regular Expressions to Constrain Input in ASP.NET&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998271.aspx"&gt;How To: Protect From SQL Injection in ASP.NET&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998274.aspx"&gt;How To: Prevent Cross-Site Scripting in ASP.NET&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-8788783625124050027?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/osbYQpstz_vyEyXaKoDwK3g8A3Y/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/osbYQpstz_vyEyXaKoDwK3g8A3Y/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/osbYQpstz_vyEyXaKoDwK3g8A3Y/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/osbYQpstz_vyEyXaKoDwK3g8A3Y/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/NKJR665E4jg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/8788783625124050027/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=8788783625124050027" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/8788783625124050027?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/8788783625124050027?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/NKJR665E4jg/how-to-protect-from-injection-attacks.html" title="How To: Protect From Injection Attacks in ASP.NET" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/how-to-protect-from-injection-attacks.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4AQ3o6fCp7ImA9WhdWE00.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-4886719545710302457</id><published>2011-09-06T13:58:00.002+05:30</published><updated>2011-09-06T15:25:42.414+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-06T15:25:42.414+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>TextBox with TextMode="MultiLine" is not woking in asp.net</title><content type="html">By default TextBox won't support Maxlength when we set TextMode="MultiLine".&lt;br /&gt;
To support maxlength we have to call javascript function to restrict the number of characters.&lt;br /&gt;
&lt;br /&gt;
Below example solve the above problem :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;function &lt;span style="color: blue;"&gt;AdditionalInfoRestriction&lt;/span&gt;() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var txtAddInfo = document.getElementById('&amp;lt;%=txtAdditionalInformation.ClientID %&amp;gt;');&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;div style="text-align: left;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: red;"&gt; // 255 is maxlength of the textbox&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (txtAddInfo.value.length &amp;gt; 255) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var cont = txtAddInfo.value;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtAddInfo.value = cont.substring(0, 254);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (e) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/div&gt;
&amp;nbsp;&amp;lt;/script&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;asp:TextBox CssClass="txt" ID="txtAdditionalInformation" &lt;span style="color: blue;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onkeyup="return AdditionalInfoRestriction();"&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Width="440px" TextMode="MultiLine" MaxLength="250"&amp;nbsp; runat="server"&amp;gt;&lt;br /&gt;
&amp;lt;/asp:TextBox&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-4886719545710302457?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6lsVJ0wD-CvMEkQIU0EmWR14nSQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6lsVJ0wD-CvMEkQIU0EmWR14nSQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6lsVJ0wD-CvMEkQIU0EmWR14nSQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6lsVJ0wD-CvMEkQIU0EmWR14nSQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/TTN7Rxdn5PQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/4886719545710302457/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=4886719545710302457" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/4886719545710302457?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/4886719545710302457?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/TTN7Rxdn5PQ/textbox-with-textmodemultiline-is-not.html" title="TextBox with TextMode=&quot;MultiLine&quot; is not woking in asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/textbox-with-textmodemultiline-is-not.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4HRnk_fyp7ImA9WhdWEkQ.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-6943020576602009217</id><published>2011-09-06T13:45:00.000+05:30</published><updated>2011-09-06T13:45:37.747+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-06T13:45:37.747+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>How to access the data from Resource file from code behind or javascript in asp.net</title><content type="html">&lt;div style="color: blue;"&gt;
&lt;span style="font-size: large;"&gt;&lt;u&gt;&lt;b&gt;.aspx&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="RaisingMessages.aspx.cs"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits="RaisingMessages" %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;Validation&amp;lt;/title&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function ValidatePage() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var fName = document.getElementById("txtFirstName");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var lName = document.getElementById("txtLastName");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fName.value == "") {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;// access resource file from javascript&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert(&lt;b style="color: blue;"&gt;'&amp;lt;%= Resources.MessageResource.Mandatory_FirstName %&amp;gt;'&lt;/b&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if (lName.value == "") {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert('Message from resource file : ' + '&amp;lt;%= Resources.MessageResource.Mandatory_LastName %&amp;gt;');&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label ID="lblFirstName" runat="server" Text="First Name"&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox ID="txtFirstName" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label ID="lblLastName" runat="server" Text="Last Name"&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox ID="txtLastName" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td colspan="2"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnClientClick="return ValidatePage();" onclick="btnSubmit_Click" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td colspan="2"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label ID="lblResult" runat="server" Text=""&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;span style="color: blue; font-family: Arial,Helvetica,sans-serif; font-size: large;"&gt;&lt;b&gt;.aspx.cs&lt;/b&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;protected void btnSubmit_Click(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;// access resource file from code behind&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblResult.Text = &lt;b style="color: blue;"&gt;Resources.MessageResource.Result_Msg &lt;/b&gt;+ ": First Name : " +&amp;nbsp;&amp;nbsp;&amp;nbsp; txtFirstName.Text.Trim() + ": Last Name : " + txtLastName.Text.Trim();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;u style="color: blue;"&gt;&lt;b&gt;Resource File&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/--C23v5xDUuA/TmXV1eBe1xI/AAAAAAAAB-w/_FavBW2IbvU/s1600/resourcefile.bmp" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="110" src="http://3.bp.blogspot.com/--C23v5xDUuA/TmXV1eBe1xI/AAAAAAAAB-w/_FavBW2IbvU/s400/resourcefile.bmp" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-6943020576602009217?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_h_FPxI_ibLDIsrUqIrxasvgCN8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_h_FPxI_ibLDIsrUqIrxasvgCN8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_h_FPxI_ibLDIsrUqIrxasvgCN8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_h_FPxI_ibLDIsrUqIrxasvgCN8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/vZRXhagD7DU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/6943020576602009217/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=6943020576602009217" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/6943020576602009217?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/6943020576602009217?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/vZRXhagD7DU/how-to-access-data-from-resource-file.html" title="How to access the data from Resource file from code behind or javascript in asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/--C23v5xDUuA/TmXV1eBe1xI/AAAAAAAAB-w/_FavBW2IbvU/s72-c/resourcefile.bmp" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/09/how-to-access-data-from-resource-file.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEAHQno4fCp7ImA9WhdXFkU.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-3322889043595262828</id><published>2011-08-29T16:15:00.003+05:30</published><updated>2011-08-30T12:15:33.434+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T12:15:33.434+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>How to make your website off line  using app_offline.htm</title><content type="html">&lt;br /&gt;
&lt;span style="font-family: Arial; font-size: small;"&gt;If  you place a file with this name (&lt;b&gt;app_offline.htm&lt;/b&gt;) in the root of a web application  directory, ASP.NET 2.0 will shut-down the application, unload the  application domain from the server, and stop processing any new incoming  requests for that application.&amp;nbsp; ASP.NET will also  then respond to all requests for dynamic pages in the application by  sending back the content of the app_offline.htm file (for example: you  might want to have a “site under construction” or “down for maintenance”  message).&lt;/span&gt; &lt;br /&gt;
&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;This  provides a convenient way to take down your application while you are  making big changes or copying in lots of new page functionality (and you  want to avoid the annoying problem of people hitting and activating  your site in the middle of a content update).&amp;nbsp; It  can also be a useful way to immediately unlock and unload a SQL Express  or Access database whose .mdf or .mdb data files are residing in the  /app_data directory.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;Once  you remove the app_offline.htm file, the next request into the  application will cause ASP.NET to load the application and app-domain  again, and life will continue along as normal.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;u&gt;&lt;b&gt;Sample app_offline.htm&amp;nbsp;&lt;/b&gt;&lt;/u&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&amp;gt;&lt;br /&gt;
&amp;lt;html xmlns="http://www.w3.org/1999/xhtml" &amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;Application Offline&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;style&amp;nbsp; type="text/css"&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; div {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; background-color:#ffffcc;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; padding-top:10px;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; padding-bottom:10px;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; padding-left:10px;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; padding-right:10px;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; border-style:solid;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; border-color:Black;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; border-width:1px;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This application is currently offline.&amp;nbsp; To enable the application, remove the&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app_offline.htm file from the application root directory.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-3322889043595262828?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gpWFJHD3x5t89FwHDsxUpHM4Kpo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gpWFJHD3x5t89FwHDsxUpHM4Kpo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gpWFJHD3x5t89FwHDsxUpHM4Kpo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gpWFJHD3x5t89FwHDsxUpHM4Kpo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/mMArBWtSdR4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/3322889043595262828/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=3322889043595262828" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/3322889043595262828?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/3322889043595262828?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/mMArBWtSdR4/how-to-make-your-site-off-line-using.html" title="How to make your website off line  using app_offline.htm" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/08/how-to-make-your-site-off-line-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4HRn89fCp7ImA9WhdXFkU.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-7432924988935841457</id><published>2011-08-26T14:45:00.003+05:30</published><updated>2011-08-30T11:28:57.164+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T11:28:57.164+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>Advantages and Disadvantages of Frames</title><content type="html">&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;
A frames page itself contains no visible content, it contains  instructions on which pages to show simultaneously and how they will be  displayed within the browser window . Think of it as a clear overlay,  much like a paneled window frame - except this window frame allows you  to look into different rooms of the house. A frames page can contain  references to many other pages, but usually they consist of references  to pages to be used as the header, the content, a left hand menu bar and  a perhaps a footer bar. When a hyperlink is clicked in one frame, say  the left hand navigation window, it will open a page in the content  window, or the target frame.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
This makes site-wide changes easy to implement (especially when used in  conjunction with Cascading Style Sheets) as you can change the items  such as the menu bar and logo for your site in one page, and that will  update the entire site.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
Using a frame for the header (top) area or navigation bar of your pages  will also make it static (fixed) so visitors can easily access menus  etc... no more scrolling back up the page.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
All this sounds great, but there are a number of points you need to  consider before implementing a framed site, especially when using  WYSIWYG (What You See Is What You Get) web page editors .&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1)&lt;/b&gt; Many search engines cannot index framed sites. Because the home page  is merely a frame, with very little content or hyperlinks to follow,  search engine spiders may stop dead on the page and have 'nothing to  report'. A way around this is the proper implementation of Meta tags and  use of the "noframes" tag. &lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2)&lt;/b&gt; If a search engine does manage to spider your site, visitors from  search engines may land on the content pages, rather than the  full-framed version, i.e. they may arrive on your site and all they will  see is the menu bar.&lt;/span&gt; 	&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;Search Engines&lt;/h3&gt;&lt;blockquote&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Search engines don't deal with frames well. Some search engines can't  follow framed pages at all, but even the best search engines will have  problems. More importantly, many search engines &lt;i&gt;choose&lt;/i&gt; not to index frames because they are so problematic.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Although search engines can theoretically index frames well enough,  there is no way to reliably organize them in a database and display them  in results pages using the correct framesets. Remember that search  engines find individual pages with the relevant content, and then have  to work backwards to determine which frameset each page belongs to. How  would they do that? Answer: They can't, so they don't try.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;In theory, for very small databases, there might be some way to track  and record framesets. This would be impractical for large search  engines, but it would also be hopelessly unreliable. For example, if a  page appears in two different framesets, how would a search engine know  which frameset to use when that page is returned in a result? What  happens when a page is moved from one frameset to another, or placed in a  frameset temporarily — how would the search engines know? There are  many other such problems which make frames unsuitable for search result  pages.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;So.... search engines can't reconstruct framesets from individual  pages. The only option is to show the pages isolated (independent of  their frameset).  Therefore most search listings to framed pages result  in broken framesets.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;The situation with search engines will not change for two reasons:&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;ol&gt;&lt;li style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;The root of the problem is with frames themselves, not the search  engines, so there is little hope that search engines will "get better"  at dealing with them.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;Frames are out of fashion, especially amongst the types of site the  search engines are trying to target, so the problems associated with  frames are not a priority for search engines.&lt;/span&gt; &lt;/li&gt;
&lt;/ol&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;i&gt;&lt;b&gt;Note&lt;/b&gt;:&lt;/i&gt; Search engines index the "noframes" content of a  frameset, which is why search engines will often show a site's  description as: "Sorry, your browser doesn't support frames so you are  unable to view this website". That's not going to attract many visitors!  You can get around this to some extent by providing better noframes  content, but it's more work and will never have the same results as  standard pages.&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;b&gt;3) Non-frames capable browsers.&lt;/b&gt; Fortunately, only 1% of visitors  browsers fall into this category. Once again the use of the 'noframes'  tag will assist, but to be used effectively you basically need to create  two sites, one framed, one not - the "time saving" is suddenly gone.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4) Bookmarking.&lt;/b&gt; A visitor cannot bookmark a specific page in your site  without requiring additional customised scripting for each page. Even  then there is a risk of visitors landing on the content frame, with no  navigation frames to view.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5) &lt;/b&gt;Visitor opinion. Many find frames annoying.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;6) Copyright issues.&lt;/b&gt; You'll need to ensure that all links within your  site that point to external sources open in a new window to avoid  copyright wrangles. There have been legal precedents in relation to this  issue. Many site owners object to their content appearing in someone  else's frame, to the point that special "frame busting" code is used.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;7) Internal linking.&lt;/b&gt; Special attention will need to be paid to your  internal links to ensure that any page pointing to, for example, the  home page opens as a "whole page", otherwise the framed home page will  appear in the target window, causing confusion to visitors.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;8) Printing issues. &lt;/b&gt;Visitors need to take further steps within their  print settings to ensure the information they want is printed correctly.  In most cases, a full page cannot be printed as displayed on the  screen, only in sections corresponding to the frame.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;9) Scroll bars, divider bars&lt;/b&gt;. If your framed site uses a number of  frames, scroll bars can prove to be unsightly. These can be removed, but  check compatibility with other popular browsers. (See further resources  at the end of this article).&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;10) External linkages to your site&lt;/b&gt;. If other sites wish to link to  specific pages in your site, it is more difficult for them to do so.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;11) Refresh/Reload problems.&lt;/b&gt; Again, special care needs to be taken with  coding otherwise&amp;nbsp;&amp;nbsp; when a visitor tries to refresh a particular page,  they may be taken back to the original frameset. A common problem.&lt;/span&gt; 	&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://searchenginewatch.com/webmasters/frames.html" target="_blank"&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt; 	&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-7432924988935841457?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/DNewMWPEybFA1Ty9hhBeMduQdiM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DNewMWPEybFA1Ty9hhBeMduQdiM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/DNewMWPEybFA1Ty9hhBeMduQdiM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DNewMWPEybFA1Ty9hhBeMduQdiM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/Ep25_6-cwrY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/7432924988935841457/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=7432924988935841457" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/7432924988935841457?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/7432924988935841457?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/Ep25_6-cwrY/advantages-and-disadvantages-of-frames.html" title="Advantages and Disadvantages of Frames" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/08/advantages-and-disadvantages-of-frames.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4ARn4yeCp7ImA9WhdXFkU.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-7586386378881366144</id><published>2011-08-26T14:30:00.000+05:30</published><updated>2011-08-30T11:29:07.090+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T11:29:07.090+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>Working with frames in asp.net</title><content type="html">&lt;span class="clsBlurb"&gt;&lt;br /&gt;
&lt;b&gt;Introduction&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Any developer who has had the dubious task of  developing a Web site utilizing frames knows it can be an uphill battle.  Many argue that frames should be avoided at all costs, while others  realize how they can benefit a Web site's user interface.  When my team  had to develop a Web site that displayed pdf's in a management  dashboard, we knew frames were the way to go. Unfortunately, we were not  sure how to best work with frames in ASP.NET. When I used my list of  normal search engines/newsgroups, I could not find much in the way of  useful information. Here is one reply I got when asking how to best work  with frames in .NET: &lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt; 	Ok, My list of suggestion for Frames.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt; 	Frames are Evil&lt;/li&gt;
&lt;li&gt;The Devil created Frames&lt;/li&gt;
&lt;li&gt; 	If you are having a problem related to the Target, refer to item 1&lt;/li&gt;
&lt;li&gt; 	If you are trying to refresh data in a particular frame, refer to 1&lt;/li&gt;
&lt;/ol&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class="clsBlurb"&gt;  I think you get the idea.  The fact of the matter is frames can provide  an aesthetically pleasing site, which in many situations is more  user-friendly. This of course is only the case if you avoid the pitfalls  of frames, such as multiple scroll bars and too many frame windows. I  will not address these pitfalls in this article because there is  certainly an over-abundance of information/opinions on that subject. In  my opinion frames have gotten a bad reputation from users because so  many developers misused them. On the other hand they have a well  deserved reputation from the developer side because in the past they  were very difficult to work with. The purpose of this article is to show  you that this is no longer the case. I will also present one  alternative to using frames, called Smart Navigation.&lt;br /&gt;
&lt;br /&gt;
In the end we solved the problem of working with frames by utilizing a  mix of JavaScript code and the Attributes property of .NET Web Forms.  This is essentially the key behind working with frames in .NET.&lt;br /&gt;
&lt;/span&gt;&lt;b&gt;&lt;span class="clsTitle"&gt;Frames and Frame Alternatives&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="clsBlurb"&gt; 						Although this article will be used to address the usage of frames  in .NET, it is important to talk about the use of frames and some  alternatives.  My team has developed the majority of our sites without  frames because they did not fit into a model in which they were  required. We use frames when we need to present the users with a control  or set of controls that maintain a certain state, while another part of  the page needs to load a file in or some other type of control(s). The  MSDN site illustrates a good use of frames in its library section: &lt;a href="http://msdn.microsoft.com/library/default.asp"&gt; http://msdn.microsoft.com/library/default.asp&lt;/a&gt;  In the past we have also used frames to control screen refresh. On an  ASP 2.0  or 3.0 page, the entire page would refresh any time you needed  to perform a server side event. One alternative to solving the screen  refresh issue in ASP.NET is Smart Navigation. This tag can be set at  page level through page properties, or at site level through web.config.  With this turned on, only the controls within the form tag will be  refreshed. So if you have other images, headers, etc., the users will  not get screen flicker.  It is important to note that behind the scenes  ASP.NET is using Iframes, so this will only work on IE5.0 and greater  browsers. The use of inline frames allows for this targeted refresh  because each frame is treated independently. The following link will  provide you with more information on Iframes and some issues related to  them: http://www.cs.tut.fi/~jkorpela/html/iframe.html&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="clsBlurb"&gt;&lt;br /&gt;
To see how Smart Navigation can be used, let's take a look at an example. &lt;br /&gt;
&lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;
&lt;span style="font-size: small;"&gt;&amp;lt;%@ Page Language="vb" AutoEventWireup="false" 
Codebehind="smart_tag.aspx.vb" Inherits="asptoday_frames.smart_tag" 
smartNavigation="True"%&amp;gt;
&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&amp;gt;
&amp;lt;HTML&amp;gt;
	&amp;lt;HEAD&amp;gt;
		&amp;lt;title&amp;gt;smart_tag&amp;lt;/title&amp;gt;
		&amp;lt;meta content="Microsoft Visual Studio.NET 7.0" 
name="GENERATOR"&amp;gt;
		&amp;lt;meta content="Visual Basic 7.0" name="CODE_LANGUAGE"&amp;gt;
		&amp;lt;meta content="JavaScript" name="vs_defaultClientScript"&amp;gt;
		&amp;lt;meta content="http://schemas.microsoft.com/intellisense/ie5"    
name="vs_targetSchema"&amp;gt;
	&amp;lt;/HEAD&amp;gt;
	&amp;lt;body MS_POSITIONING="GridLayout"&amp;gt;
		&amp;lt;form id="frmImage" style="Z-INDEX: 101; LEFT: 6px; POSITION: 
absolute; TOP: 18px" runat="server"&amp;gt;
&amp;lt;asp:button id="btnRefresh" style="Z-INDEX: 104; LEFT: 19px; POSITION: 
absolute; TOP: 13px" runat="server" Text="Refresh"&amp;gt;&amp;lt;/asp:button&amp;gt;&amp;lt;asp:label id="lblRefresh" 
style="Z-INDEX: 105; LEFT: 96px; POSITION: absolute; TOP: 18px" 
runat="server"&amp;gt;&amp;lt;/asp:label&amp;gt;&amp;lt;/form&amp;gt;
		&amp;lt;IMG style="Z-INDEX: 103; LEFT: 27px; WIDTH: 507px; POSITION: 
absolute; TOP: 87px; HEIGHT: 259px" height="259" alt="" src="test.GIF" 
width="507"&amp;gt;
		&amp;lt;IMG style="Z-INDEX: 102; LEFT: 16px; WIDTH: 507px; POSITION: 
absolute; TOP: 78px; HEIGHT: 259px" height="259" alt="" src="test.GIF" 
width="507"&amp;gt;
	&amp;lt;/body&amp;gt;
&amp;lt;/HTML&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;u&gt;Code Behind&lt;/u&gt; &lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;
&lt;span style="font-size: small;"&gt;using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class smart_tag : System.Web.UI.Page
{
	private System.Web.UI.WebControls.Button withEventsField_btnRefresh;
	protected System.Web.UI.WebControls.Button btnRefresh {
		get { return withEventsField_btnRefresh; }
		set {
			if (withEventsField_btnRefresh != null) {
				withEventsField_btnRefresh.Click -= btnRefresh_Click;
			}
			withEventsField_btnRefresh = value;
			if (withEventsField_btnRefresh != null) {
				withEventsField_btnRefresh.Click += btnRefresh_Click;
			}
		}
	}

	protected System.Web.UI.WebControls.Label lblRefresh;
	private void Page_Load(System.Object sender, System.EventArgs e)
	{
		this.lblRefresh.Text = "";
	}

	private void btnRefresh_Click(System.Object sender, System.EventArgs e)
	{
		this.lblRefresh.Text = "Page Refreshed";
	}
	public smart_tag()
	{
		Load += Page_Load;
	}
}&lt;/span&gt;

&lt;/span&gt;&lt;/pre&gt;At the top of the page we are setting smartNavigation="True" so that the  only the lblRefresh and btnRefresh make a roundtrip to the server.  I  have added two images at the bottom of the page to illustrate the  difference that smart navigation makes. If you set smartNavigation =  False, you will notice some flashing of the images, even when running  local to the Web server.   IFrames can be useful in forcing refresh of only part of the screen, but  it cannot fully replace the functionality that comes with working with  regular frames. The biggest drawback with Iframes is that you cannot  implement two separate form tags in the same page, which may be required  for some sites.      						&lt;/span&gt;    					&lt;br /&gt;
&lt;span class="clsTitle"&gt;Questions Regarding Frames&lt;/span&gt;&lt;br /&gt;
&lt;span class="clsBlurb"&gt; 						The main problem that most people have when working with frames is  cross-frame communication. There are several consistent questions I see  on frames including:  &lt;br /&gt;
&lt;ul&gt;&lt;li&gt; How do I pass data to another frame? &lt;/li&gt;
&lt;li&gt; How do I refresh a specific frame?&lt;br /&gt;
This issue is compounded when you start dealing with pop-up windows.  &lt;/li&gt;
&lt;/ul&gt;&lt;/span&gt;    					&lt;br /&gt;
&lt;span class="clsTitle"&gt;The Solution&lt;/span&gt;&lt;br /&gt;
&lt;span class="clsBlurb"&gt; 						Solving the above described problems has become much easier with  some basic knowledge of the windows and frames properties in javascript  and the ASP.NET Attributes property. In this article I am going to break  my code up into several sections, starting with a very easy to follow  hello world style example. After that I will address working with  pop-ups, adding a very useful HTML control into the mix.     						&lt;/span&gt;    					&lt;br /&gt;
&lt;span class="clsTitle"&gt;The Code&lt;/span&gt;&lt;br /&gt;
&lt;span class="clsBlurb"&gt; 						      						&lt;/span&gt;    					&lt;br /&gt;
&lt;span class="clsTitle"&gt;Goal #1: Pass data between left and right frames&lt;/span&gt;&lt;br /&gt;
&lt;span class="clsBlurb"&gt; 						&lt;b&gt;&lt;u&gt;UI Design&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Before I get into the code, it is important that you receive the visual of the two frames that we will be working with:  &lt;img src="http://www.15seconds.com/graphics/issue/030528_01.gif" /&gt; &lt;br /&gt;
&lt;b&gt;&lt;u&gt;CODE&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
For the purpose of brevity, I will exclude code automatically generated by Web forms. &lt;br /&gt;
To start we have the simple default.htm page that will contain our two aspx pages.  &lt;br /&gt;
&lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;
&lt;span style="font-size: small;"&gt;&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&amp;gt;
&amp;lt;html&amp;gt;
	&amp;lt;head&amp;gt;
		&amp;lt;title&amp;gt;How to Work with frames in .Net&amp;lt;/title&amp;gt;
		&amp;lt;meta name="vs_defaultClientScript" content="JavaScript"&amp;gt;
		&amp;lt;meta name="vs_targetSchema" 
content="http://schemas.microsoft.com/intellisense/ie5"&amp;gt;
		&amp;lt;meta name="GENERATOR" content="Microsoft Visual Studio.NET 
7.0"&amp;gt;
		&amp;lt;meta name="ProgId" content="VisualStudio.HTML"&amp;gt;
		&amp;lt;meta name="Originator" content="Microsoft Visual Studio.NET 
7.0"&amp;gt;
	&amp;lt;/head&amp;gt;
	&amp;lt;frameset border="1" frameborder="1" framespacing="0" 
cols="30%,70%"&amp;gt;

&amp;lt;frame name="left frame" src="leftframe.aspx"/&amp;gt;
&amp;lt;frame name="right frame" src="rightframe.aspx"/&amp;gt;

&amp;lt;/frameset&amp;gt;
&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;Next is the left frame page, which will contain a mix of javascript and  VB.NET code. The mix of this code will enable us to pass a text string  from a textbox on the left frame to a textbox in the right frame.  &lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;&lt;span style="font-size: small;"&gt;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class leftframe : System.Web.UI.Page
{
	protected System.Web.UI.WebControls.Button btnTright;
	protected System.Web.UI.WebControls.Button btnPop;

	protected System.Web.UI.WebControls.TextBox txtTright;
	private void Page_Load(System.Object sender, System.EventArgs e)
	{
		//enclose the add attributes in the not is post back block, so they
		// are called to be added only once.
		if (!IsPostBack) {
			btnTright.Attributes.Add("onclick", "javascript:tranRight(txtTransferRight.value)");
			btnPop.Attributes.Add("onclick", "javascript:openWindow()");
			//remove file name from session
			Session.Remove("fileName");
		}

	}
	public leftframe()
	{
		Load += Page_Load;
	}

}&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;The key to working with frames is the Attributes property along with its  Add method, which allows us to dynamically insert calls to javascript  functions, passing in our server side control's data. The Attributes  property allows you to declare any event handler that is associated with  a specific Web control. Any of the attributes that you add to the  controls collection will be rendered at run time. For a text box you  could add a call to the textchanged event. Note, if you do make  reference to an unsupported event, it will be ignored by the browser.  For now you can ignore the session remove, which will be needed for a  later part of this article.    Here is the HTML code that exists for the left frame page.  &lt;br /&gt;
&lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;
&lt;span style="font-size: small;"&gt;&amp;lt;%@ Page Language="vb" AutoEventWireup="false" 
Codebehind="leftframe.aspx.vb" Inherits="asptoday_frames.leftframe"%&amp;gt;
&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&amp;gt;
&amp;lt;HTML&amp;gt;
	&amp;lt;HEAD&amp;gt;
		&amp;lt;title&amp;gt;leftframe&amp;lt;/title&amp;gt;
		&amp;lt;meta content="Microsoft Visual Studio.NET 7.0" 
name="GENERATOR"&amp;gt;
		&amp;lt;meta content="Visual Basic 7.0" name="CODE_LANGUAGE"&amp;gt;
		&amp;lt;meta content="JavaScript" name="vs_defaultClientScript"&amp;gt;
		&amp;lt;meta content="http://schemas.microsoft.com/intellisense/ie5" 
name="vs_targetSchema"&amp;gt;
	&amp;lt;/HEAD&amp;gt;
	&amp;lt;body MS_POSITIONING="GridLayout"&amp;gt;
&amp;lt;form id="frmTransterRight" method="post" runat="server"&amp;gt;
&amp;lt;asp:button id="btnTransferRight" style="Z-INDEX: 101; LEFT: 23px; 
POSITION: absolute; TOP: 100px" runat="server" Text="Send to right frame" 
Width="131px"&amp;gt;&amp;lt;/asp:button&amp;gt;&amp;lt;asp:textbox 
id="txtTransferRight" style="Z-INDEX: 102; LEFT: 26px; POSITION: absolute; TOP: 
64px" runat="server" Width="170px" Height="24px"&amp;gt;Text to go to right 
frame&amp;lt;/asp:textbox&amp;gt;&amp;lt;asp:button id="btnPop" style="Z-INDEX: 103; 
LEFT: 24px; POSITION: absolute; TOP: 136px" runat="server" Text="Open Pop-Up" 
Width="129px"&amp;gt;&amp;lt;/asp:button&amp;gt;&amp;lt;/form&amp;gt;
&amp;lt;script language="javascript"&amp;gt;		

//this function takes a value (ltext) and transmits that to the left hand frame

function tranRight(ltext)
{
   parent.frames(1).document.forms("frmReceive").item("txtReceive").value = ltext;	
}
&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;Notice the tranRight javascript function, which will enable us to  transfer the text in the left frame to the right frame. The tranRight  function is called from the click event of the btnTransferRight button  Parent.Frames(1) indicates we are targeting the right frame, while  Parent.Frames(0) is the current page that the code is getting  initialized from.  When the btnTransferRight button is clicked, only the  left frame will be re-rendered because the button's event is set to run  client side.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="clsBlurb"&gt;&lt;br /&gt;
With that simple code, we have established basic interaction between our frames.     						&lt;/span&gt;    					&lt;br /&gt;
&lt;span class="clsTitle"&gt;&lt;b&gt;Goal #2&lt;/b&gt;: Pass text between pop-up and right frame&lt;/span&gt;&lt;br /&gt;
&lt;span class="clsBlurb"&gt; 						In this section we will pass text from a pop-up screen launched from the left frame to a textbox in the right frame.  UI Design  The "Send Via QS" button will trigger the event that will transmit the  text. The lower section of this UI will be addressed in Goal#3 &lt;br /&gt;
&lt;img src="http://www.15seconds.com/graphics/issue/030528_02.gif" /&gt; &lt;br /&gt;
&lt;b&gt;&lt;u&gt;UI Code&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
The first key is the code which allows this pop-up to be launched from  the left frame. This is a line in the original left frame codebehind  listed as part of example #1: &lt;br /&gt;
&lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt; 
&lt;span style="font-size: small;"&gt;btnPop.Attributes.Add("onclick", "javascript:openWindow()")&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;This is the JavaScript which launches this pop-up: &lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;
&lt;span style="font-size: small;"&gt;function openWindow() 
{ msgWindow=window.open("popup.aspx","", 
"fullscreen=no,toolbar=no,status=yes,menubar=yes,scrollbars=no,resizable=no,
directories=no,location=no,width=500,height=400"); 
if (msgWindow.opener == null) msgWindow.opener = self; }&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;Now that we have established the launch of the popup, we can look at the pageload event of the popup Web form.  &lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;&lt;span style="font-size: small;"&gt;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class popup : System.Web.UI.Page
{
	protected System.Web.UI.HtmlControls.HtmlInputButton btnLfile;
	protected System.Web.UI.WebControls.Button btnWFrame;
	protected System.Web.UI.WebControls.Button btnHframe;
	protected System.Web.UI.WebControls.TextBox txtPop;

	protected System.Web.UI.HtmlControls.HtmlInputFile myFile;
	private void Page_Load(System.Object sender, System.EventArgs e)
	{
		//enclose the add attributes in the not is post back block, so they
		// are called to be added only once.
		if (!IsPostBack) {
			btnSendQS.Attributes.Add("onclick", "javascript:openpdf(txtPop.value)");
			btnSendSession.Attributes.Add("onclick", "javascript:openviacache()");
		}
	}
	public popup()
	{
		Load += Page_Load;
	}
}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;Once again we are adding attributes to two of the buttons which call  javascript functions. The first button is the one we will concentrate on  for the time being. As you can see we are passing in the value of the  txtPop textbox.  Here is the javascript which transmits the text. &lt;br /&gt;
&lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;
&lt;span style="font-size: small;"&gt;function transferText(strTxtTransfer) { 
window.opener.parent.frames[1].location.href = "rightframe.aspx?strText="+ strTxtTransfer; window.close(); }&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;By using window.opener.parent we are able to reference the original  frame, so we then in turn can reference the right frame to transmit the  data to (by inserting and index of 1).  The text itself is encased  within a query string. This query string is then read by the right frame  on load of the page and presented within that page's textbox.      						&lt;/span&gt;    					&lt;br /&gt;
&lt;span class="clsTitle"&gt;Goal #3 Use HTML input control in pop-up to load user file to server and then launch pdf in right fr&lt;/span&gt;&lt;br /&gt;
&lt;span class="clsBlurb"&gt; 						In this section we will be using the HTML input control to load a  pdf file to the Web server and then subsequently call for the load of  that pdf into the right frame. The HTML input control, which is provided  with .NET, makes file uploading far more simple by presenting users  with the standard Windows file browsing window.   &lt;b&gt;&lt;u&gt;UI Design&lt;/u&gt;&lt;/b&gt; &lt;br /&gt;
&lt;img src="http://www.15seconds.com/graphics/issue/030528_02.gif" /&gt; &lt;br /&gt;
&lt;b&gt;&lt;u&gt;UI Code&lt;/u&gt;&lt;/b&gt; &lt;br /&gt;
&lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;
&lt;span style="font-size: small;"&gt;&amp;lt;form id="Form1" method="post" encType="multipart/form-data" 
runat="server"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;The first section of code to review is the HTML in the pop-up.aspx page. In the form you must add the  Tag encType="multipart/form-data". This will allow the HTML input control to work.  &lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;
&lt;span style="font-size: small;"&gt; private void btnLoadFile_ServerClick(System.Object sender, System.EventArgs e)
{
	//Grab the file name from its fully qualified path at client 
	string strFileName = myFile.PostedFile.FileName;
	// only the attched file name not its path
	string strShortFile = System.IO.Path.GetFileName(strFileName);
	//Save uploaded file to server @ rootweb\pdf_files and add to session
	myFile.PostedFile.SaveAs(Server.MapPath(".") + "\\pdf_files\\" + strShortFile);
	Session.Add("fileName", Server.MapPath(".") + "\\pdf_files\\" + strShortFile);
}&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;This codebehind for the loadfile button saves the file up to the server  and stores the name and location in session. This was the reason for the  clearing of session that was seen in the codebehind of the left frame  page. The browse button is what presents the user with the standard  Windows Explorer file selection box and fills in the lower text box.  This functionality is all encapsulated in the HTML input control.   Below is the HTML and JavaScript that exists behind the pop-up aspx page.  &lt;br /&gt;
&lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;
&lt;span style="font-size: small;"&gt;&amp;lt;%@ Page Language="vb" AutoEventWireup="false" Codebehind="popup.aspx.vb" 
Inherits="asptoday_frames.popup"%&amp;gt;
&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&amp;gt;
&amp;lt;HTML&amp;gt;
	&amp;lt;HEAD&amp;gt;
		&amp;lt;title&amp;gt;popup&amp;lt;/title&amp;gt;
		&amp;lt;meta content="Microsoft Visual Studio.NET 7.0" 
name="GENERATOR"&amp;gt;
		&amp;lt;meta content="Visual Basic 7.0" name="CODE_LANGUAGE"&amp;gt;
		&amp;lt;meta content="JavaScript" name="vs_defaultClientScript"&amp;gt;
		&amp;lt;meta content="http://schemas.microsoft.com/intellisense/ie5" 
name="vs_targetSchema"&amp;gt;
	&amp;lt;/HEAD&amp;gt;
	&amp;lt;body MS_POSITIONING="GridLayout"&amp;gt;
		&amp;lt;form id="frmPopUp" method="post" encType="multipart/form-data" 
runat="server"&amp;gt;
			&amp;lt;asp:label id="Label1" style="Z-INDEX: 106; LEFT: 26px; 
POSITION: absolute; TOP: 90px" runat="server" Height="20px" ForeColor="Red" 
Font-Bold="True" Width="280px"&amp;gt;Session 
Example&amp;lt;/asp:label&amp;gt;&amp;lt;asp:label id="lblSession" style="Z-INDEX: 
107; LEFT: 26px; POSITION: absolute; TOP: 117px" runat="server" Height="20px" 
ForeColor="DimGray" Font-Bold="True" Width="459px" Font-
Size="Smaller"&amp;gt;Click Browse, Find PDF file, click load file and then the 
send via session button&amp;lt;/asp:label&amp;gt;&amp;nbsp;
			&amp;lt;INPUT id="btnLoadFile" style="Z-INDEX: 100; LEFT: 334px; 
WIDTH: 79px; POSITION: absolute; TOP: 148px; HEIGHT: 23px" type="button" 
value="LoadFile " runat="server"&amp;gt;
			&amp;lt;asp:button id="btnSendSession" style="Z-INDEX: 101; 
LEFT: 18px; POSITION: absolute; TOP: 179px" runat="server" Width="112px" 
Text="Send Via Session"&amp;gt;&amp;lt;/asp:button&amp;gt;&amp;lt;asp:button 
id="btnSendQS" style="Z-INDEX: 102; LEFT: 266px; POSITION: absolute; TOP: 41px" 
runat="server" Width="113px" Text="Send Via 
QS"&amp;gt;&amp;lt;/asp:button&amp;gt;&amp;lt;INPUT id="myFile" style="Z-INDEX: 103; 
LEFT: 18px; WIDTH: 311px; POSITION: absolute; TOP: 148px; HEIGHT: 22px" 
type="file" size="32" name="myFile" runat="server"&amp;gt;
			&amp;lt;asp:textbox id="txtPop" style="Z-INDEX: 104; LEFT: 25px; 
POSITION: absolute; TOP: 43px" runat="server" Width="225px"&amp;gt;Transmit to 
right frame&amp;lt;/asp:textbox&amp;gt;&amp;lt;asp:label id="lblQS" style="Z-INDEX: 
105; LEFT: 32px; POSITION: absolute; TOP: 13px" runat="server" ForeColor="Red" 
Font-Bold="True" Width="251px"&amp;gt;Query String 
Example&amp;lt;/asp:label&amp;gt;&amp;lt;/form&amp;gt;
		&amp;lt;script language="javascript"&amp;gt;			

function transferText(strTxtTransfer)
{
window.opener.parent.frames[1].location.href = "rightframe.aspx?strText="+ strTxtTransfer;
window.close();
}


function openviacache()
{
window.opener.parent.frames[1].location.href = "rightframe.aspx";
window.close();
}
		&amp;lt;/script&amp;gt;
	&amp;lt;/body&amp;gt;
&amp;lt;/HTML&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;A refresh of the right frame is called from the "Send Via Cache" button,  which has an onclick event call to the openviacache JavaScript  function. This function calls for the re-load of the right frame page.   We want the page to reload so the code in the page load event of the  right hand frame page will execute.   The code behind of the right frame page looks for the fname session key  and loads a pdf in the page based on that filename.  In this block of  code, I first test to make sure the file passed from session is a pdf.  This is because I am using Response.contentType so that the browser can  interpret the file as a pdf and display it properly in the browser. &lt;br /&gt;
&lt;pre&gt;&lt;span style="color: blue; font-size: x-small;"&gt;&lt;span style="font-size: small;"&gt;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class rightframe : System.Web.UI.Page
{

	protected System.Web.UI.WebControls.TextBox txtFleft;
	private void Page_Load(System.Object sender, System.EventArgs e)
	{
		//Put user code to initialize the page here

		string strTxtTransfer = Request.QueryString.Get("strText");
		//first find out if this page is getting called from the send via qs button by looking for a query string
		if (!string.IsNullOrEmpty(strTxtTransfer)) {
			this.txtReceive.Text = strTxtTransfer;
		// if session fname is populated and the file is a pdf load the pdf
		} else if (!string.IsNullOrEmpty((Session["filename"])) &amp;amp; Strings.Right((Session["filename"]), 3) == "pdf") {
			Response.Expires = 0;
			Response.Buffer = true;
			Response.Clear();
			Response.ContentType = "application/pdf";
			Response.WriteFile(Session["filename"]);
			Response.End();
		//if session has a value and it is not a pdf send an error message
		} else if (!string.IsNullOrEmpty((Session["filename"])) &amp;amp; Strings.Right((Session["filename"]), 3) != "pdf") {
			var _with1 = this.txtReceive;
			_with1.ForeColor = Color.Red;
			_with1.Text = "sorry you must choose a pdf file to display";
		}
	}
	public rightframe()
	{
		Load += Page_Load;
	}
}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;The final result looks like this:   &lt;img src="http://www.15seconds.com/graphics/issue/030528_03.gif" /&gt;     						&lt;/span&gt;    					&lt;br /&gt;
&lt;span class="clsTitle"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="clsBlurb"&gt;&lt;/span&gt;    					&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-7586386378881366144?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8IUFKIU55SpZpYQG32UbqiQCpAk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8IUFKIU55SpZpYQG32UbqiQCpAk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8IUFKIU55SpZpYQG32UbqiQCpAk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8IUFKIU55SpZpYQG32UbqiQCpAk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/zEtQbU7MCgo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/7586386378881366144/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=7586386378881366144" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/7586386378881366144?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/7586386378881366144?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/zEtQbU7MCgo/working-with-frames-in-aspnet.html" title="Working with frames in asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/08/working-with-frames-in-aspnet.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4CRH05eyp7ImA9WhdXFkU.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-1939486607094489238</id><published>2011-08-25T19:03:00.002+05:30</published><updated>2011-08-30T11:29:25.323+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T11:29:25.323+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>How to avoid copy, paste and backspace error on AsyncFileUpload control in asp.net</title><content type="html">&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Use below code to avoid above problems&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ajax:AsyncFileUpload runat="server" ID="flTripImages"&lt;br /&gt;
&lt;blockquote&gt;OnClientUploadStarted="SetTermAgrement" OnUploadedFileError="flTripImages_UploadedError"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnClientUploadComplete="EnableCheckBox"&lt;br /&gt;
OnUploadedComplete="flTripImages_UploadedComplete"&lt;br /&gt;
&lt;b&gt;oncontextmenu="return false;" &lt;/b&gt;/&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;
use &lt;b&gt;oncontextmenu="return false;" &lt;/b&gt;to avoid the contextmenu on the upload control, this will take care of above problems&lt;br /&gt;
&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-1939486607094489238?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/J2pKBD77O-_Cxb6qPDN5Sd8gzds/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J2pKBD77O-_Cxb6qPDN5Sd8gzds/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/J2pKBD77O-_Cxb6qPDN5Sd8gzds/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J2pKBD77O-_Cxb6qPDN5Sd8gzds/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/7lG-OA2BlXg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/1939486607094489238/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=1939486607094489238" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/1939486607094489238?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/1939486607094489238?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/7lG-OA2BlXg/how-to-avoid-copy-paste-and-backspace.html" title="How to avoid copy, paste and backspace error on AsyncFileUpload control in asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/08/how-to-avoid-copy-paste-and-backspace.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4CRH05fCp7ImA9WhdXFkU.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-2617932277921597591</id><published>2011-08-24T12:03:00.000+05:30</published><updated>2011-08-30T11:29:25.324+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T11:29:25.324+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>Passing a control.ClientID to a javascript function in asp.net</title><content type="html">&lt;br /&gt;
Use below code to pass control client id to javascript function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;asp:TextBox ID="&lt;b&gt;demo1&lt;/b&gt;" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;
&amp;lt;img src="images/cal.gif" &lt;b&gt;onclick="javascript:NewCssCal('&amp;lt;%= demo1.ClientID %&amp;gt;')"&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; style="cursor: pointer"            alt="sdf" /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-2617932277921597591?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BFHjaH0CB7h_rfwtjs9OVbp-tQg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BFHjaH0CB7h_rfwtjs9OVbp-tQg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BFHjaH0CB7h_rfwtjs9OVbp-tQg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BFHjaH0CB7h_rfwtjs9OVbp-tQg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/_8HLwoJ-vRs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/2617932277921597591/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=2617932277921597591" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/2617932277921597591?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/2617932277921597591?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/_8HLwoJ-vRs/passing-controlclientid-to-javascript.html" title="Passing a control.ClientID to a javascript function in asp.net" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/08/passing-controlclientid-to-javascript.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4DSH0zfyp7ImA9WhdXEUo.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-5999878751118465504</id><published>2011-08-24T11:35:00.001+05:30</published><updated>2011-08-24T12:59:39.387+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-24T12:59:39.387+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>how to implement facebook like button in asp.net pages or master page</title><content type="html">&lt;b&gt;1) &lt;strong&gt;One&lt;/strong&gt;&lt;/b&gt;&lt;strong style="font-weight: normal;"&gt; way&lt;/strong&gt; to add the like button on your site.go to this page,&lt;br /&gt;
&lt;a href="http://developers.facebook.com/docs/reference/plugins/like-box" rel="nofollow"&gt;http://developers.facebook.com/docs/reference/plugins/like-box&lt;/a&gt;&lt;br /&gt;
just enter your facebook details then press on the "Get Code" button, u will get the copy &amp;amp; paste code like below.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;This is an example:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fplatform&amp;amp;amp;width=292&amp;amp;amp;colorscheme=light&amp;amp;amp;show_faces=true&amp;amp;amp;border_color&amp;amp;amp;stream=true&amp;amp;amp;header=true&amp;amp;amp;height=427" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:427px;" allowTransparency="true"&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;2) Another way&lt;/b&gt; To implement facebook like button copy &amp;amp; paste the below code replace "&lt;b&gt;MahindraHomestays" with "your facebook id"&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: left;"&gt;&amp;nbsp; &amp;lt;iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2F&lt;b&gt;MahindraHomestays&lt;/b&gt;&amp;amp;amp;layout=button_count&amp;amp;amp;show_faces=false&amp;amp;amp;width=50&amp;amp;amp;action=like&amp;amp;amp;font&amp;amp;amp;colorscheme=light&amp;amp;amp;height=21"&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scrolling="no" frameborder="0" style="border: none; overflow: hidden; width: 80px;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height: 21px;" allowtransparency="true"&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;iframe align="left" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=challa&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=B0056UOUC8&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;iframe align="left" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=challa&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=B001FA1O18&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-5999878751118465504?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/LkQ--GLeENvQC_bH_iOXklrU3Ng/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LkQ--GLeENvQC_bH_iOXklrU3Ng/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/LkQ--GLeENvQC_bH_iOXklrU3Ng/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LkQ--GLeENvQC_bH_iOXklrU3Ng/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/cuVVD8GWaOQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/5999878751118465504/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=5999878751118465504" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/5999878751118465504?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/5999878751118465504?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/cuVVD8GWaOQ/how-to-implement-facebook-like-button.html" title="how to implement facebook like button in asp.net pages or master page" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>1</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/08/how-to-implement-facebook-like-button.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4DRH49fyp7ImA9WhdXFkU.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-5984075290794146486</id><published>2011-08-19T15:28:00.000+05:30</published><updated>2011-08-30T11:29:35.067+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T11:29:35.067+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>Wikileaks releases some of the Top Black Money Holders from India</title><content type="html">&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-1zoevq66_2M/Tk4x2DZekNI/AAAAAAAAB9k/INNwd8QMa-U/s1600/List+of+Black+Money+Holders+from+Wiki+Leaks-03-08-2011.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="384" src="http://2.bp.blogspot.com/-1zoevq66_2M/Tk4x2DZekNI/AAAAAAAAB9k/INNwd8QMa-U/s640/List+of+Black+Money+Holders+from+Wiki+Leaks-03-08-2011.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-5984075290794146486?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ecfCJC2XiaU_2vyIShiOMreWZ9o/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ecfCJC2XiaU_2vyIShiOMreWZ9o/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ecfCJC2XiaU_2vyIShiOMreWZ9o/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ecfCJC2XiaU_2vyIShiOMreWZ9o/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/ShkelY8OB-U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/5984075290794146486/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=5984075290794146486" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/5984075290794146486?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/5984075290794146486?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/ShkelY8OB-U/wikileaks-releases-some-of-top-black.html" title="Wikileaks releases some of the Top Black Money Holders from India" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-1zoevq66_2M/Tk4x2DZekNI/AAAAAAAAB9k/INNwd8QMa-U/s72-c/List+of+Black+Money+Holders+from+Wiki+Leaks-03-08-2011.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/08/wikileaks-releases-some-of-top-black.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQERHk4eip7ImA9WhdXFkU.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-4112280057661348818</id><published>2011-08-17T13:35:00.001+05:30</published><updated>2011-08-30T11:35:05.732+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T11:35:05.732+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>How To: Prevent Cross-Site Scripting in ASP.NET</title><content type="html">&lt;h2 class="dtH1"&gt;Applies To&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;ASP.NET version 1.1&lt;/li&gt;
&lt;li&gt;ASP.NET version 2.0&lt;/li&gt;
&lt;/ul&gt;&lt;h2 class="dtH1"&gt;Summary&lt;/h2&gt;&lt;blockquote&gt;&lt;div style="text-align: left;"&gt;This How To shows how you can help protect your ASP.NET applications  from cross-site scripting attacks by using proper input validation  techniques and by encoding the output. It also describes a number of  other protection mechanisms that you can use in addition to these two  main countermeasures.&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style="text-align: justify;"&gt;Cross-site scripting (XSS) attacks exploit vulnerabilities in Web  page validation by injecting client-side script code. Common  vulnerabilities that make your Web applications susceptible to  cross-site scripting attacks include failing to properly validate input,  failing to encode output, and trusting the data retrieved from a shared  database. To protect your application against cross-site scripting  attacks, assume that all input is malicious. Constrain and validate all  input. Encode all output that could, potentially, include HTML  characters. This includes data read from files and databases.&lt;/div&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;h2 class="dtH1"&gt;Objectives&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;Understand the common cross-site scripting vulnerabilities in Web page validation.&lt;/li&gt;
&lt;li&gt;Apply countermeasures for cross-site scripting attacks.&lt;/li&gt;
&lt;li&gt;Constrain input by using regular expressions, type checks, and ASP.NET validator controls.&lt;/li&gt;
&lt;li&gt;Constrain output to ensure the browser does not execute HTML tags that contain script code. &lt;/li&gt;
&lt;li&gt;Review potentially dangerous HTML tags and attributes and evaluate countermeasures.&lt;/li&gt;
&lt;/ul&gt;&lt;h2 class="dtH1"&gt;Overview&lt;/h2&gt;Cross-site scripting attacks exploit vulnerabilities in Web page  validation by injecting client-side script code. The script code embeds  itself in response data, which is sent back to an unsuspecting user. The  user's browser then runs the script code. Because the browser downloads  the script code from a trusted site, the browser has no way of  recognizing that the code is not legitimate, and Microsoft Internet  Explorer security zones provide no defense. Cross-site scripting attacks  also work over HTTP and HTTPS (SSL) connections. &lt;br /&gt;
One of the most serious examples of a cross-site scripting attack  occurs when an attacker writes script to retrieve the authentication  cookie that provides access to a trusted site and then posts the cookie  to a Web address known to the attacker. This enables the attacker to  spoof the legitimate user's identity and gain illicit access to the Web  site.&lt;br /&gt;
Common vulnerabilities that make your Web application susceptible to cross-site scripting attacks include:  &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Failing to constrain and validate input.&lt;/li&gt;
&lt;li&gt;Failing to encode output.&lt;/li&gt;
&lt;li&gt;Trusting data retrieved from a shared database.&lt;/li&gt;
&lt;/ul&gt;&lt;h3 class="dtH1"&gt;Guidelines&lt;/h3&gt;The two most important countermeasures to prevent cross-site scripting attacks are to:  &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;Constrain input&lt;/b&gt;. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Encode output&lt;/b&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;h4 class="dtH1"&gt;Constrain Input&lt;/h4&gt;Start by assuming that all input is malicious. Validate input type, length, format, and range.   &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;To constrain input supplied through server controls, use ASP.NET validator controls such as &lt;b&gt;RegularExpressionValidator&lt;/b&gt; and &lt;b&gt;RangeValidator&lt;/b&gt;. &lt;/li&gt;
&lt;li&gt;To constrain input supplied through client-side HTML input controls  or input from other sources such as query strings or cookies, use the &lt;b&gt;System.Text.RegularExpressions.Regex&lt;/b&gt; class in your server-side code to check for expected using regular expressions.&lt;/li&gt;
&lt;li&gt;To validate types such as integers, doubles, dates, and currency  amounts, convert the input data to the equivalent .NET Framework data  type and handle any resulting conversion errors. &lt;/li&gt;
&lt;/ul&gt;For more information about and examples of how to constrain input, see &lt;a href="http://msdn.microsoft.com/en-us/library/bb355989.aspx"&gt;How To: Protect From Injection Attacks in ASP.NET&lt;/a&gt;.&lt;br /&gt;
&lt;h4 class="dtH1"&gt;Encode Output&lt;/h4&gt;Use the &lt;b&gt;HttpUtility.HtmlEncode&lt;/b&gt; method to encode output if it contains input from the user or from other sources such as databases. &lt;b&gt;HtmlEncode&lt;/b&gt;  replaces characters that have special meaning in HTML-to-HTML variables  that represent those characters. For example, &amp;lt; is replaced with &lt;b&gt;&amp;amp;lt;&lt;/b&gt; and &lt;b&gt;"&lt;/b&gt; is replaced with &lt;b&gt;&amp;amp;quot;&lt;/b&gt;. Encoded data does not cause the browser to execute code. Instead, the data is rendered as harmless HTML.&lt;br /&gt;
Similarly, use &lt;b&gt;HttpUtility.UrlEncode&lt;/b&gt; to encode output URLs if they are constructed from input.&lt;br /&gt;
&lt;h2 class="dtH1"&gt;Summary of Steps&lt;/h2&gt;To prevent cross-site scripting, perform the following steps:  &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;Step 1. Check that ASP.NET request validation is enabled. &lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Step 2. Review ASP.NET code that generates HTML output. &lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Step 3. Determine whether HTML output includes input parameters. &lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Step 4. Review potentially dangerous HTML tags and attributes. &lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Step 5. Evaluate countermeasures.&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h2 class="dtH1"&gt;Step 1. Check That ASP.NET Request Validation Is Enabled&lt;/h2&gt;By default, request validation is enabled in Machine.config. Verify  that request validation is currently enabled in your server's  Machine.config file and that your application does not override this  setting in its Web.config file. Check that &lt;b&gt;validateRequest&lt;/b&gt; is set to &lt;b&gt;true &lt;/b&gt;as shown in the following code example.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="code"&gt;&amp;lt;system.web&amp;gt;&amp;lt;pages buffer="true" validateRequest="true" /&amp;gt;&amp;lt;/system.web&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="code"&gt;&amp;nbsp;&lt;/pre&gt;You can disable request validation on a page-by-page basis. Check  that your pages do not disable this feature unless necessary. For  example, you may need to disable this feature for a page if it contains a  free-format, rich-text entry field designed to accept a range of HTML  characters as input. For more information about how to safely handle  this type of page, see &lt;a href="http://msdn.microsoft.com/en-us/library/ff649310.aspx#paght000004_step5"&gt;Step 5. Evaluate Countermeasures&lt;/a&gt;.&lt;br /&gt;
&lt;b&gt;To test that ASP.NET request validation is enabled&lt;/b&gt;  &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Create an ASP.NET page that disables request validation. To do this, set &lt;b&gt;ValidateRequest="false"&lt;/b&gt;, as shown in the following code example. &lt;pre class="code"&gt;&amp;lt;%@ Page Language="C#" ValidateRequest="false" %&amp;gt;
&amp;lt;html&amp;gt;
 &amp;lt;script runat="server"&amp;gt;
  void btnSubmit_Click(Object sender, EventArgs e)
  {
    // If ValidateRequest is false, then 'hello' is displayed
    // If ValidateRequest is true, then ASP.NET returns an exception
    Response.Write(txtString.Text);
  }
 &amp;lt;/script&amp;gt;
 &amp;lt;body&amp;gt;
  &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;asp:TextBox id="txtString" runat="server" 
                 Text="&amp;lt;script&amp;gt;alert('hello');&amp;lt;/script&amp;gt;" /&amp;gt;
    &amp;lt;asp:Button id="btnSubmit" runat="server"   
                OnClick="btnSubmit_Click" 
                Text="Submit" /&amp;gt;
  &amp;lt;/form&amp;gt;
 &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
  &lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Run the page. It displays &lt;b&gt;Hello&lt;/b&gt; in a message box because the script in &lt;b&gt;txtString&lt;/b&gt; is passed through and rendered as client-side script in your browser.&lt;/li&gt;
&lt;li&gt;Set &lt;b&gt;ValidateRequest="true"&lt;/b&gt; or remove the &lt;b&gt;ValidateRequest&lt;/b&gt; page attribute and browse to the page again. Verify that the following error message is displayed.  &lt;pre class="code"&gt;A potentially dangerous Request.Form value was detected from the client (txtString="&amp;lt;script&amp;gt;alert('hello...").
  &lt;/pre&gt;This indicates that ASP.NET request validation is active and has  rejected the input because it includes potentially dangerous HTML  characters.  &lt;br /&gt;
&lt;blockquote class="dtBlock"&gt;&lt;b&gt;Note&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Do not rely on ASP.NET request validation. Treat  it as an extra precautionary measure in addition to your own input  validation.&lt;/blockquote&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;h2 class="dtH1"&gt;Step 2. Review ASP.NET Code That Generates HTML Output&lt;/h2&gt;ASP.NET writes HTML as output in two ways, as shown in the following code examples.&lt;br /&gt;
&lt;pre class="code"&gt;Response.Write
&amp;lt;% =
  &lt;/pre&gt;Search your pages to locate where HTML and URL output is returned to the client.&lt;br /&gt;
&lt;h2 class="dtH1"&gt;Step 3. Determine Whether HTML Output Includes Input Parameters&lt;/h2&gt;Analyze your design and your page code to determine whether the  output includes any input parameters. These parameters can come from a  variety of sources. The following list includes common input sources:  &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;Form fields&lt;/b&gt;, such as the following. &lt;pre class="code"&gt;Response.Write(name.Text);
Response.Write(Request.Form["name"]);
Query Strings
Response.Write(Request.QueryString["name"]);
  &lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Query strings&lt;/b&gt;, such as the following: &lt;pre class="code"&gt;Response.Write(Request.QueryString["username"]);
  &lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Databases and data access methods&lt;/b&gt;, such as the following: &lt;pre class="code"&gt;SqlDataReader reader = cmd.ExecuteReader();
Response.Write(reader.GetString(1));
  &lt;/pre&gt;Be particularly careful with data read from a database if it is shared by other applications. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Cookie collection&lt;/b&gt;, such as the following: &lt;pre class="code"&gt;Response.Write(
Request.Cookies["name"].Values["name"]);
  &lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Session and application variables&lt;/b&gt;, such as the following: &lt;pre class="code"&gt;Response.Write(Session["name"]);
Response.Write(Application["name"]);
  &lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;In addition to source code analysis, you can also perform a simple test by typing text such as "&lt;b&gt;XYZ&lt;/b&gt;" in form fields and testing the output. If the browser displays "&lt;b&gt;XYZ&lt;/b&gt;" or if you see "&lt;b&gt;XYZ&lt;/b&gt;" when you view the source of the HTML, your Web application is vulnerable to cross-site scripting. &lt;br /&gt;
To see something more dynamic, inject &amp;lt;&lt;b&gt;script&lt;/b&gt;&amp;gt;&lt;b&gt;alert('hello');&lt;/b&gt;&amp;lt;&lt;b&gt;/script&lt;/b&gt;&amp;gt;  through an input field. This technique might not work in all cases  because it depends on how the input is used to generate the output.&lt;br /&gt;
&lt;h2 class="dtH1"&gt;Step 4. Review Potentially Dangerous HTML Tags and Attributes&lt;/h2&gt;If you dynamically create HTML tags and construct tag attributes with  potentially unsafe input, make sure you HTML-encode the tag attributes  before writing them out. &lt;br /&gt;
The following .aspx page shows how you can write HTML directly to the return page by using the &amp;lt;&lt;b&gt;asp:Literal&lt;/b&gt;&amp;gt;  control. The code takes user input of a color name, inserts it into the  HTML sent back, and displays text in the color entered. The page uses &lt;b&gt;HtmlEncode&lt;/b&gt; to ensure the inserted text is safe.&lt;br /&gt;
&lt;pre class="code"&gt;&amp;lt;%@ Page Language="C#" AutoEventWireup="true"%&amp;gt;

&amp;lt;html&amp;gt;
  &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;div&amp;gt;
      Color:&amp;amp;nbsp;&amp;lt;asp:TextBox ID="TextBox1" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;br /&amp;gt;
      &amp;lt;asp:Button ID="Button1" runat="server" Text="Show color" 
         OnClick="Button1_Click" /&amp;gt;&amp;lt;br /&amp;gt;
      &amp;lt;asp:Literal ID="Literal1" runat="server"&amp;gt;&amp;lt;/asp:Literal&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/form&amp;gt;
&amp;lt;/html&amp;gt;

&amp;lt;script runat="server"&amp;gt;
  private void Page_Load(Object Src, EventArgs e)
  {
    protected void Button1_Click(object sender, EventArgs e)
    {
      Literal1.Text = @"&amp;lt;span style=""color:" 
        + Server.HtmlEncode(TextBox1.Text)
        + @"""&amp;gt;Color example&amp;lt;/span&amp;gt;";
    }           
  }
&amp;lt;/Script&amp;gt;
  &lt;/pre&gt;&lt;h3 class="dtH1"&gt;Potentially Dangerous HTML Tags&lt;/h3&gt;While not an exhaustive list, the following commonly used HTML tags could allow a malicious user to inject script code:  &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&amp;lt;&lt;b&gt;applet&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;body&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;embed&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;frame&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;script&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;frameset&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;html&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;iframe&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;img&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;style&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;layer&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;link&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;ilayer&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;meta&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;&lt;b&gt;object&lt;/b&gt;&amp;gt;&lt;/li&gt;
&lt;/ul&gt;An attacker can use HTML attributes such as &lt;b&gt;src&lt;/b&gt;, &lt;b&gt;lowsrc&lt;/b&gt;, &lt;b&gt;style&lt;/b&gt;, and &lt;b&gt;href&lt;/b&gt; in conjunction with the preceding tags to inject cross-site scripting. For example, the &lt;b&gt;src&lt;/b&gt; attribute of the &amp;lt;&lt;b&gt;img&lt;/b&gt;&amp;gt; tag can be a source of injection, as shown in the following examples.&lt;br /&gt;
&lt;pre class="code"&gt;&amp;lt;img src="javascript:alert('hello');"&amp;gt;
&amp;lt;img src="java&amp;amp;#010;script:alert('hello');"&amp;gt;
&amp;lt;img src="java&amp;amp;#X0A;script:alert('hello');"&amp;gt;
  &lt;/pre&gt;An attacker can also use the &amp;lt;&lt;b&gt;style&lt;/b&gt;&amp;gt; tag to inject a script by changing the MIME type as shown in the following.&lt;br /&gt;
&lt;pre class="code"&gt;&amp;lt;style TYPE="text/javascript"&amp;gt;
  alert('hello');
&amp;lt;/style&amp;gt;
  &lt;/pre&gt;&lt;h2 class="dtH1"&gt;Step 5. Evaluate Countermeasures&lt;/h2&gt;When you find ASP.NET code that generates HTML using some input, you  need to evaluate appropriate countermeasures for your specific  application. Countermeasures include:  &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;Encode HTML output.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Encode URL output.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Filter user input.&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h3 class="dtH1"&gt;Encode HTML Output&lt;/h3&gt;If you write text output to a Web page and you do not know if the  text contains HTML special characters (such as &amp;lt;, &amp;gt;, and &lt;b&gt;&amp;amp;&lt;/b&gt;), pre-process the text by using the &lt;b&gt;HttpUtility.HtmlEncode&lt;/b&gt; method as shown in the following code example. Do this if the text came from user input, a database, or a local file.&lt;br /&gt;
&lt;pre class="code"&gt;Response.Write(HttpUtility.HtmlEncode(Request.Form["name"]));
  &lt;/pre&gt;Do not substitute encoding output for checking that input is  well-formed and correct. Use it as an additional security precaution.&lt;br /&gt;
&lt;h3 class="dtH1"&gt;Encode URL Output&lt;/h3&gt;If you return URL strings that contain input to the client, use the &lt;b&gt;HttpUtility.UrlEncode&lt;/b&gt; method to encode these URL strings as shown in the following code example.&lt;br /&gt;
&lt;pre class="code"&gt;Response.Write(HttpUtility.UrlEncode(urlString));
  &lt;/pre&gt;&lt;h3 class="dtH1"&gt;Filter User Input&lt;/h3&gt;If you have pages that need to accept a range of HTML elements, for  example through some kind of rich text input field, you must disable  ASP.NET request validation for the page. If you have several pages that  do this, create a filter that allows only the HTML elements that you  want to accept. A common practice is to restrict formatting to safe HTML  elements such as bold (&amp;lt;&lt;b&gt;b&lt;/b&gt;&amp;gt;) and italic (&amp;lt;&lt;b&gt;i&lt;/b&gt;&amp;gt;).&lt;br /&gt;
&lt;b&gt;To safely allow restricted HTML input&lt;/b&gt;  &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Disable ASP.NET request validation by the adding the &lt;b&gt;ValidateRequest="false"&lt;/b&gt; attribute to the &lt;b&gt;@ Page&lt;/b&gt; directive. &lt;/li&gt;
&lt;li&gt;Encode the string input with the &lt;b&gt;HtmlEncode&lt;/b&gt; method.&lt;/li&gt;
&lt;li&gt;Use a &lt;b&gt;StringBuilder&lt;/b&gt; and call its &lt;b&gt;Replace&lt;/b&gt; method to selectively remove the encoding on the HTML elements that you want to permit. &lt;/li&gt;
&lt;/ol&gt;The following .aspx page code shows this approach. The page disables ASP.NET request validation by setting &lt;b&gt;ValidateRequest="false"&lt;/b&gt;. It HTML-encodes the input and then selectively allows the &amp;lt;&lt;b&gt;b&lt;/b&gt;&amp;gt; and &amp;lt;&lt;b&gt;i&lt;/b&gt;&amp;gt; HTML elements to support simple text formatting. &lt;br /&gt;
&lt;pre class="code"&gt;&amp;lt;%@ Page Language="C#" ValidateRequest="false"%&amp;gt;

&amp;lt;script runat="server"&amp;gt;

  void submitBtn_Click(object sender, EventArgs e)
  {
    // Encode the string input
    StringBuilder sb = new StringBuilder(
                            HttpUtility.HtmlEncode(htmlInputTxt.Text));
    // Selectively allow &lt;b&gt; &amp;lt;b&amp;gt; and &amp;lt;i&amp;gt;&lt;/b&gt;
&lt;b&gt;    sb.Replace("&amp;amp;lt;b&amp;amp;gt;", "&amp;lt;b&amp;gt;");&lt;/b&gt;
&lt;b&gt;    sb.Replace("&amp;amp;lt;/b&amp;amp;gt;", "&lt;/b&gt;");
    sb.Replace("&amp;amp;lt;i&amp;amp;gt;", "&amp;lt;i&amp;gt;");
    sb.Replace("&amp;amp;lt;/i&amp;amp;gt;", "");
    Response.Write(sb.ToString());
  }
&amp;lt;/script&amp;gt;

&amp;lt;html&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;asp:TextBox ID="htmlInputTxt" Runat="server" 
                     TextMode="MultiLine" Width="318px"
                     Height="168px"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;
        &amp;lt;asp:Button ID="submitBtn" Runat="server" 
                     Text="Submit" OnClick="submitBtn_Click" /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
  &lt;/pre&gt;&lt;h2 class="dtH1"&gt;Additional Considerations&lt;/h2&gt;In addition to the techniques discussed previously in this How To,  use the following countermeasures as further safe guards to prevent  cross-site scripting:   &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;Set the correct character encoding&lt;/b&gt;. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Do not rely on input sanitization&lt;/b&gt;. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Use the HttpOnly cookie option&lt;/b&gt;. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Use the &lt;/b&gt;&amp;lt;&lt;b&gt;frame&lt;/b&gt;&amp;gt;&lt;b&gt; security attribute&lt;/b&gt;. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Use the innerText property instead of innerHTML&lt;/b&gt;. &lt;/li&gt;
&lt;/ul&gt;&lt;h3 class="dtH1"&gt;Set the Correct Character Encoding&lt;/h3&gt;To successfully restrict valid data for your Web pages, you should  limit the ways in which the input data can be represented. This prevents  malicious users from using canonicalization and multi-byte escape  sequences to trick your input validation routines. A multi-byte escape  sequence attack is a subtle manipulation that uses the fact that  character encodings, such as uniform translation format-8 (UTF-8), use  multi-byte sequences to represent non-ASCII characters. Some byte  sequences are not legitimate UTF-8, but they may be accepted by some  UTF-8 decoders, thus providing an exploitable security hole.&lt;br /&gt;
ASP.NET allows you to specify the character set at the page level or at the application level by using the &amp;lt;&lt;b&gt;globalization&lt;/b&gt;&amp;gt;  element in the Web.config file. The following code examples show both  approaches and use the ISO-8859-1 character encoding, which is the  default in early versions of HTML and HTTP.&lt;br /&gt;
To set the character encoding at the page level, use the &amp;lt;&lt;b&gt;meta&lt;/b&gt;&amp;gt; element or the &lt;b&gt;ResponseEncoding&lt;/b&gt; page-level attribute as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="code"&gt;&lt;span style="color: #444444;"&gt;&amp;lt;meta http-equiv="Content Type" &lt;/span&gt;
&lt;span style="color: #444444;"&gt;      content="text/html; charset=ISO-8859-1" /&amp;gt;&lt;/span&gt;

&lt;span style="color: #444444;"&gt;OR&lt;/span&gt;
&lt;span style="color: #444444;"&gt;&amp;lt;% @ Page ResponseEncoding="iso-8859-1" %&amp;gt;&lt;/span&gt;
  &lt;/pre&gt;To set the character encoding in the Web.config file, use the following configuration.&lt;br /&gt;
&lt;pre class="code"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="code"&gt;&amp;lt;configuration&amp;gt;
   &amp;lt;system.web&amp;gt;
      &amp;lt;globalization 
         requestEncoding="iso-8859-1"
         responseEncoding="iso-8859-1"/&amp;gt;
   &amp;lt;/system.web&amp;gt;
&amp;lt;/configuration&amp;gt;
  &lt;/pre&gt;&lt;h3 class="dtH1"&gt;Validating Unicode Characters&lt;/h3&gt;Use the following code to validate Unicode characters in a page.&lt;br /&gt;
&lt;pre class="code"&gt;using System.Text.RegularExpressions;
. . .

public class WebForm1 : System.Web.UI.Page
{
  private void Page_Load(object sender, System.EventArgs e)
  {
    // Name must contain between 1 and 40 alphanumeric characters
    // and (optionally) special characters such as apostrophes  
    // for names such as O'Dell

    if (!Regex.IsMatch(Request.Form["name"],
               @"^[\p{L}\p{Zs}\p{Lu}\p{Ll}\']{1,40}$"))
      throw new ArgumentException("Invalid name parameter");

    // Use individual regular expressions to validate other parameters
    . . .
  }
}
  &lt;/pre&gt;The following explains the regular expression shown in the preceding code:   &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;^&lt;/b&gt; means start looking at this position.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;\p{ ..}&lt;/b&gt; matches any character in the named character class specified by &lt;b&gt;{..}&lt;/b&gt;. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;{L}&lt;/b&gt; performs a left-to-right match. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;{Lu}&lt;/b&gt; performs a match of uppercase. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;{Ll}&lt;/b&gt; performs a match of lowercase. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;{Zs}&lt;/b&gt; matches separator and space. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;'&lt;/b&gt;matches apostrophe.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;{1,40}&lt;/b&gt; specifies the number of characters: no less than 1 and no more than 40. &lt;/li&gt;
&lt;li&gt;$ means stop looking at this position.&lt;/li&gt;
&lt;/ul&gt;&lt;h3 class="dtH1"&gt;Do Not Rely on Input Sanitization&lt;/h3&gt;A common practice is for code to attempt to sanitize input by  filtering out known unsafe characters. Do not rely on this approach  because malicious users can usually find an alternative means of  bypassing your validation. Instead, your code should check for known  secure, safe input. Table 1 shows various safe ways to represent some  common characters.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="label"&gt;&lt;b&gt;Table 1: Character Representation&lt;/b&gt;&lt;/div&gt;&lt;div class="tablediv"&gt;&lt;table class="dtTABLE"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Characters&lt;/th&gt;&lt;th&gt;Decimal&lt;/th&gt;&lt;th&gt;Hexadecimal&lt;/th&gt;&lt;th&gt;HTML Character Set&lt;/th&gt;&lt;th&gt;Unicode&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;b&gt; " &lt;/b&gt;(double quotation marks)&lt;/td&gt;&lt;td&gt;&amp;amp;#34&lt;/td&gt;&lt;td&gt;&amp;amp;#x22&lt;/td&gt;&lt;td&gt;&amp;amp;quot;&lt;/td&gt;&lt;td&gt;\u0022&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;b&gt; ' &lt;/b&gt;(single quotation mark)&lt;/td&gt;&lt;td&gt;&amp;amp;#39&lt;/td&gt;&lt;td&gt;&amp;amp;#x27&lt;/td&gt;&lt;td&gt;&amp;amp;apos;&lt;/td&gt;&lt;td&gt;\u0027&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;b&gt;&amp;amp;&lt;/b&gt; (ampersand)&lt;/td&gt;&lt;td&gt;&amp;amp;#38&lt;/td&gt;&lt;td&gt;&amp;amp;#x26&lt;/td&gt;&lt;td&gt;&amp;amp;amp;&lt;/td&gt;&lt;td&gt;\u0026&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&amp;lt; (less than)&lt;/td&gt;&lt;td&gt;&amp;amp;#60&lt;/td&gt;&lt;td&gt;&amp;amp;#x3C&lt;/td&gt;&lt;td&gt;&amp;amp;lt;&lt;/td&gt;&lt;td&gt;\u003c&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&amp;gt; (greater than)&lt;/td&gt;&lt;td&gt;&amp;amp;#62&lt;/td&gt;&lt;td&gt;&amp;amp;#x3E&lt;/td&gt;&lt;td&gt;&amp;amp;gt;&lt;/td&gt;&lt;td&gt;\u003e&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3 class="dtH1"&gt;&amp;nbsp;&lt;/h3&gt;&lt;h3 class="dtH1"&gt;Use the HttpOnly Cookie Option&lt;/h3&gt;Internet Explorer 6 Service Pack 1 and later supports an &lt;b&gt;HttpOnly&lt;/b&gt; cookie attribute, which prevents client-side scripts from accessing a cookie from the &lt;b&gt;document.cookie&lt;/b&gt;  property. Instead, the script returns an empty string. The cookie is  still sent to the server whenever the user browses to a Web site in the  current domain.&lt;br /&gt;
&lt;blockquote class="dtBlock"&gt;&lt;b&gt;Note&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Web browsers that do not support the &lt;b&gt;HttpOnly&lt;/b&gt;  cookie attribute either ignore the cookie or ignore the attribute,  which means that it is still subject to cross-site scripting attacks. &lt;/blockquote&gt;The &lt;b&gt;System.Net.Cookie&lt;/b&gt; class in Microsoft .NET Framework version 2.0 supports an &lt;b&gt;HttpOnly&lt;/b&gt; property. The &lt;b&gt;HttpOnly&lt;/b&gt; property is always set to true by Forms authentication. &lt;br /&gt;
Earlier versions of the .NET Framework (versions 1.0 and 1.1) require that you add code similar to the following to the &lt;b&gt;Application&lt;/b&gt;_&lt;b&gt;EndRequest&lt;/b&gt; event handler in your application Global.asax file to explicitly set the &lt;b&gt;HttpOnly&lt;/b&gt; attribute.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="code"&gt;protected void Application_EndRequest(Object sender, EventArgs e) 
{
  string authCookie = FormsAuthentication.FormsCookieName;
  foreach (string sCookie in Response.Cookies) 
  {
    // Just set the HttpOnly attribute on the Forms 
    // authentication cookie. Skip this check to set the attribute 
    // on all cookies in the collection

    if (sCookie.Equals(authCookie))
    { 
      // Force HttpOnly to be added to the cookie header
      Response.Cookies[sCookie].Path += ";HttpOnly";
    }
  }
}
  &lt;/pre&gt;&lt;h3 class="dtH1"&gt;Use the &amp;lt;frame&amp;gt; Security Attribute&lt;/h3&gt;Internet Explorer 6 and later support a new &lt;b&gt;security&lt;/b&gt; attribute for the &amp;lt;&lt;b&gt;frame&lt;/b&gt;&amp;gt; and &amp;lt;&lt;b&gt;iframe&lt;/b&gt;&amp;gt; elements. You can use the &lt;b&gt;security&lt;/b&gt;  attribute to apply the user's Restricted Sites Internet Explorer  security zone settings to an individual frame or iframe. By default, the  Restricted Sites zone does not support script execution. &lt;br /&gt;
If you use the &lt;b&gt;security&lt;/b&gt; attribute, it must be set to &lt;b&gt;"restricted"&lt;/b&gt; as shown in the following.&lt;br /&gt;
&lt;pre class="code"&gt;&amp;lt;frame security="restricted" src="http://www.somesite.com/somepage.htm"&amp;gt;&amp;lt;/frame&amp;gt;
  &lt;/pre&gt;&lt;h3 class="dtH1"&gt;Use the innerText Property Instead of innerHTML&lt;/h3&gt;If you use the &lt;b&gt;innerHTML&lt;/b&gt; property to build a page and the HTML is based on potentially untrusted input, you must use &lt;b&gt;HtmlEncode&lt;/b&gt; to make it safe. To avoid having to remember to do this, use &lt;b&gt;innerText&lt;/b&gt; instead. The &lt;b&gt;innerText&lt;/b&gt; property renders content safe and ensures that scripts are not executed.&lt;br /&gt;
The following example shows this approach for two HTML &amp;lt;&lt;b&gt;span&lt;/b&gt;&amp;gt; controls. The code in the &lt;b&gt;Page_Load&lt;/b&gt; method sets the text displayed in the &lt;b&gt;Welcome1&lt;/b&gt; &amp;lt;&lt;b&gt;span&lt;/b&gt;&amp;gt; element using the &lt;b&gt;innerText&lt;/b&gt; property, so HTML-encoding is unnecessary. The code sets the text in the &lt;b&gt;Welcome2&lt;/b&gt; &amp;lt;&lt;b&gt;span&lt;/b&gt;&amp;gt; element by using the &lt;b&gt;innerHtml&lt;/b&gt; property; therefore, you must &lt;b&gt;HtmlEncode&lt;/b&gt; it first to make it safe.&lt;br /&gt;
&lt;pre class="code"&gt;&amp;lt;%@ Page Language="C#" AutoEventWireup="true"%&amp;gt;

&amp;lt;html&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;span id="Welcome1" runat="server"&amp;gt; &amp;lt;/span&amp;gt;
    &amp;lt;span id="Welcome2" runat="server"&amp;gt; &amp;lt;/span&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&amp;lt;script runat="server"&amp;gt;
  private void Page_Load(Object Src, EventArgs e)
  {
    // Using InnerText renders the content safe–no need to HtmlEncode
    Welcome1.InnerText = "Hello, " + User.Identity.Name;

    // Using InnerHtml requires the use of HtmlEncode to make it safe
    Welcome2.InnerHtml = "Hello, " + 
                        Server.HtmlEncode(User.Identity.Name);
  }
&amp;lt;/Script&amp;gt;
  &lt;/pre&gt;&lt;h2 class="dtH1"&gt;Additional Resources&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb355989.aspx"&gt;How To: Protect From Injection Attacks in ASP.NET&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998271.aspx"&gt;How To: Protect From SQL Injection in ASP.NET&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998267.aspx"&gt;How To: Use Regular Expressions to Constrain Input in ASP.NET&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;iframe align="left" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=challa&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=B003P2UMP8&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe align="left" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=challa&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=B003ZX8B0U&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1537800241861894285-4112280057661348818?l=challadotnetfaq.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/qgTc-RZXfI2Pqvnm-bE3gDEaUfw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qgTc-RZXfI2Pqvnm-bE3gDEaUfw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/qgTc-RZXfI2Pqvnm-bE3gDEaUfw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qgTc-RZXfI2Pqvnm-bE3gDEaUfw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ChallaDotnetFaqsBlog/~4/aPxwVNG2wQk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://challadotnetfaq.blogspot.com/feeds/4112280057661348818/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1537800241861894285&amp;postID=4112280057661348818" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/4112280057661348818?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1537800241861894285/posts/default/4112280057661348818?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ChallaDotnetFaqsBlog/~3/aPxwVNG2wQk/how-to-prevent-cross-site-scripting-in.html" title="How To: Prevent Cross-Site Scripting in ASP.NET" /><author><name>Challa Srinivas Reddy</name><email>srinivas.ch1700@gmail.com</email></author><thr:total>0</thr:total><feedburner:origLink>http://challadotnetfaq.blogspot.com/2011/08/how-to-prevent-cross-site-scripting-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQBSXk4fip7ImA9WhdQFUU.&quot;"><id>tag:blogger.com,1999:blog-1537800241861894285.post-6301126322872777680</id><published>2011-08-17T12:58:00.001+05:30</published><updated>2011-08-17T17:29:18.736+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-17T17:29:18.736+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>Image Button alternate text (tooltip) is not working in ie 8 asp.net</title><content type="html">To solve the Image Button alternate text is not working in ie 8 asp.net problem&lt;br /&gt;
follow the below code&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;.aspx&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
asp:Image ID="imgItinerary" &amp;nbsp; ImageUrl="~/images/search_thumb.jpg" runat="server"&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;.aspx.cs&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Problem created code:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i missed out tooltip property&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; imgItinerary.AlternateText = "Image";&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Solution for the above problem:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; imgItinerary.AlternateText = "Image";&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; imgItinerary.&lt;b&gt;ToolTip &lt;/b&gt;= "Image";&lt;br /&gt;
&lt;br /&gt;
&lt;iframe align="left" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=challa&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=B00012PWZA&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe align="left" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=challa&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=B0055HMVXM&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://bl
