<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3134941485038447368</id><updated>2011-11-27T15:18:37.147-08:00</updated><category term='Ajax'/><title type='text'>AJAX</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-141753314423924256</id><published>2009-10-23T08:48:00.000-07:00</published><updated>2009-10-23T08:57:57.524-07:00</updated><title type='text'>How to make a clickable URL hyperlink in a GridView</title><content type='html'>&lt;p&gt;If you have a database column that contains a URL and you want                to make it appear in your GridView as a clickable hyperlink, change                the GridView column to a Template Field, delete the textbox in there                and add a Hyperlink control instead. Change the source to look like                this:&lt;/p&gt;              &lt;itemtemplate&gt;&lt;br /&gt;              &amp;lt;itemtemplate&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:HyperLink id=&amp;quot;HyperLink1&amp;quot;&lt;br /&gt;&lt;br /&gt;    runat=&amp;quot;server&amp;quot; Text='&amp;lt;%# Bind(&amp;quot;url&amp;quot;) %&amp;gt;' NavigateUrl='&amp;lt;%# Bind(&amp;quot;url&amp;quot;) %&amp;gt;'&amp;gt;&amp;lt;/asp:HyperLink&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/itemtemplate&amp;gt;&lt;br /&gt;              &lt;/itemtemplate&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-141753314423924256?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/141753314423924256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3134941485038447368&amp;postID=141753314423924256' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/141753314423924256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/141753314423924256'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2009/10/grid-view-properties.html' title='How to make a clickable URL hyperlink in a GridView'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-4632989398864588487</id><published>2009-05-22T06:50:00.000-07:00</published><updated>2009-05-22T07:02:07.048-07:00</updated><title type='text'></title><content type='html'>Original site : &lt;a href="http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx"&gt;http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx&lt;/a&gt;&lt;br /&gt;&lt;form id="Form1" onsubmit="javascript:return WebForm_OnSubmit();" method="post" name="Form1" action="file-upload-in-updatepanel-asp.net-ajax.aspx"&gt;&lt;div id="main"&gt;&lt;div id="contentBodyLeft"&gt;&lt;div id="contentBodyRight"&gt;&lt;div id="contentBodyCenter"&gt;&lt;div id="content"&gt;&lt;div id="entries"&gt;&lt;div class="entry"&gt;&lt;h4&gt;&lt;a id="viewpost_ascx_TitleUrl" title="Title of this entry." href="http://www.blogger.com/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx"&gt;File Upload in UpdatePanel doen't work, ASP.NET AJAX&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;color:#003366;"&gt;One of the common queries I get across my sessions is that, the File Upload control doesnt work inside an Update panel. All of us would like to implement a Gmail File Upload kind of interface and when you try to implement a similar thing using UpdatePanel (which works like a charm for other activities), it simply doesn't work.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;color:#003366;"&gt;The behaviour is expected. The File Upload Control doesnt work inside an Update Panel due to security reasons and restrictions a browser implies. They dont allow Javascript files to directly access the files in an user's sytem and dont allow to modify or access the details of a file when working with the File Upload Control.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;color:#003366;"&gt;There are a couple of ways to solve this issue, one using Update Panel and Post Back Triggers and the other using Iframes.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-family:Tahoma;color:#003366;"&gt;1. Use Update Panel, File Upload Control and use a PostBackTrigger Control to force a postback only for the File Upload Control&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="color:#003366;"&gt;This approach works well without much tweaking except for that, there would be a postback only for the File Upload Control. While the rest of the stuff happens asynchronously, using the UpdatePanel, when the user presses the "Upload" Button, the page will be refreshed. Let us examine how we can accomplish this. Place the following code within the &amp;lt;form&amp;gt; &amp;lt;/form&amp;gt; tags in your ASP.NET Page.&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="color:#a31515;"&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ScriptManager&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="ScriptManager1"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;="server"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ScriptManager&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="color:#a31515;"&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;UpdatePanel&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="UpdatePanel1"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="color:#a31515;"&gt;&lt;contenttemplate&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button1"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="20px"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;onclick&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button1_Click"&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#ff0000;"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Submit"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="128px"&lt;/span&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Label&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Label1"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Label"&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Label&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;FileUpload&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="FileUpload1"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button2"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="25px"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;onclick&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button2_Click"&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#ff0000;"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Upload"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="128px"&lt;/span&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Label&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Label2"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Label"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Label&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;&lt;contenttemplate&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;&lt;triggers&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span color="#a31515"&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;PostBackTrigger&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ControlID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button2"&lt;/span&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="COLOR: #a31515"&gt;Triggers&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="COLOR: #a31515"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;UpdatePanel&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;color:#003366;"&gt;In the Code behind, add the following lines of code:-&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;span style="font-size:130%;color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:130%;color:#0000ff;"&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;protected &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Button1_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;Label1.Text = TextBox1.Text;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Button2_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;FileUpload1.PostedFile.SaveAs(&lt;span style="color:#a31515;"&gt;@"C:\test\"&lt;/span&gt;+System.IO.&lt;span style="color:#2b91af;"&gt;Path&lt;/span&gt;.GetFileName(FileUpload1.PostedFile.FileName));&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;Label2.Text = FileUpload1.PostedFile.FileName;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;color:#003366;"&gt;If you run the above sample, you would notice that upon entering something in the TextBox and clicking "Submit" (Button1) the Label above the File Upload Content, shows the Text you typed, without a page refresh.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;color:#003366;"&gt;However, when you select a file and click on the "Upload" (Button2) Button, you would notice that a postback happens and the file gets posted to the "C:\Test\" folder and also the full path is specified in the Label 2.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;color:#003366;"&gt;In the above code, I have not taken any steps regarding validation, checking if file exists etc., since it just shows how you could accomplish File Upload within Update panel. In normal cases, you would write better code to accomplish a file upload feature.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:Tahoma;font-size:85%;color:#003366;"&gt;&lt;strong&gt;2. Use Iframes and accomplish a truly Gmail Like File Upload Interface.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Tahoma;font-size:85%;color:#003366;"&gt;I thought of writing a post on this, but did a quick research and found that there are a few solutions posted by our MVPs / Community Folks and just thought of providing a link to the same.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#003366;"&gt;&lt;a href="http://vinayakshrestha.wordpress.com/2007/03/13/uploading-files-using-aspnet-ajax-extensions/"&gt;&lt;span style="font-family:Tahoma;"&gt;http://vinayakshrestha.wordpress.com/2007/03/13/uploading-files-using-aspnet-ajax-extensions/&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:Tahoma;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:0;"&gt;&lt;span style="font-size:85%;color:#003366;"&gt;&lt;a href="http://msmvps.com/blogs/luisabreu/archive/2006/12/14/uploading-files-without-a-full-postback.aspx"&gt;&lt;span style="font-family:Tahoma;"&gt;http://msmvps.com/blogs/luisabreu/archive/2006/12/14/uploading-files-without-a-full-postback.aspx&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:Tahoma;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:0;"&gt;&lt;span style="font-family:Tahoma;font-size:85%;color:#003366;"&gt;Note that this post doesnt claim any warranty / support for the above articles, though.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:0;"&gt;&lt;span style="font-family:Tahoma;font-size:85%;color:#003366;"&gt;Cheers !!!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p class="post"&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="font-family:Tahoma;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span color="#a31515"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-4632989398864588487?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/4632989398864588487/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3134941485038447368&amp;postID=4632989398864588487' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/4632989398864588487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/4632989398864588487'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2009/05/original-site-httpgeekswithblogs.html' title=''/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-2980137762063961660</id><published>2009-05-14T07:44:00.000-07:00</published><updated>2009-05-14T08:25:11.783-07:00</updated><title type='text'>How to Deploy ASP.NET Web Application</title><content type='html'>&lt;h1&gt;&lt;span class="Apple-style-span"  style=" ;font-size:24px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;Introduction&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/h1&gt; &lt;p class="ArticleText" style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Several times we encounter a great and sophisticated web or  desktop application that does not poses it's appropriate market share just for  the reason of poorly written SETUP package and poorly designed deployment  strategy. The fact is simple: If your users are not able to easily deploy your  application then whatever sophistication or features you  provide, they will be  unable to even experience your application from the very first place! &lt;/span&gt;&lt;/p&gt;&lt;p class="ArticleText" style="text-align: justify;"&gt;&lt;/p&gt;&lt;p class="ArticleText"&gt;In this tutorial we are going to show you a set of  techniques by which you can package and deploy your web applications .....&lt;/p&gt;&lt;p class="ArticleText"&gt;&lt;span class="Apple-style-span"  style=" font-weight: bold; font-size:24px;"&gt;Alternatives&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="ArticleText"&gt;When it comes to web applications specifically, then you  will encounter many techniques that can be utilized as a deployment strategy for  your web application: &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p class="ArticleText" style="text-align: justify;"&gt;&lt;/p&gt;&lt;h2 align="left"&gt;XCOPY Deployment&lt;/h2&gt; &lt;p class="ArticleText"&gt;The most trivial technique is to simply copy your web  application files to the production server hard drive and set a virtual  directory there. The setting of a virtual directory is needed by several  deployment schemes and can be achieved from Internet Information Manager  Microsoft Management Consol (MMC snap-in). Because developers typically use the  command line order 'XCOPY' to implement this technique, this technique is  typically referred to as XCOPY Deployment. &lt;/p&gt; &lt;h2&gt;Copy Web Site&lt;/h2&gt; &lt;p class="ArticleText"&gt;&lt;em&gt;Copy Web Site &lt;/em&gt;is a new technique provided in  ASP.NET 2.0 and Microsoft Visual Studio 2005 (Available from the Website / Copy  Web Site... Menu option). Although this technique is performed from inside  Visual Studio (in contrast with the XCOPY deployment technique which is  performed from outside Visual Studio), there is no compilation performed at all.  All your pages are still in their source code form on the production server.  Some developers see this fact as a high risk on their intellectual property. Two  extra disadvantages of this technique (and in fact any other technique that does  not involve any compilation before deployment) are reduced error checking and  the slow initial page load. &lt;/p&gt; &lt;p class="ArticleText"&gt;The reduced error checking is a direct result to that no  compilation is performed and hence some errors may be discovered by your users  later. The initial page load slowness is also because nothing is compiled yet  and the entire web application has to be compiled at the time the first page is  being requested. An advantage of this technique over the XCOPY deployment is  that you have the options to deploy to the File System, the Local IIS, the FTP  Sites, and the Remote Sites. Please see figure 1.&lt;/p&gt;&lt;p class="ArticleText" style="text-align: center;"&gt;&lt;img src="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Packaging-File-System.jpg" width="578" height="455" /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="ArticleText" style="text-align: center;"&gt;Figure 1&lt;br /&gt;&lt;/p&gt;&lt;h2&gt;Pre-compilation &lt;/h2&gt; &lt;p class="ArticleText"&gt;All of the deployment methods we mentioned so far suffer  from the fact of that no compilation is performed along with the disadvantages  that comes as a direct result from this fact. To ensure fast page load and some  protection of your source code, you should pre-compile your web site before  deployment. &lt;/p&gt; &lt;p class="ArticleText"&gt;Pre-compilation can be performed in-place by just adding  '/Deployment/Precompile.axd' to the root URL of your web application and opening  the resulting URL in Internet Explore. &lt;/p&gt; &lt;p class="ArticleText"&gt;Pre-compilation can also be achieved using the command line  compiler 'aspnet_compiler'. &lt;/p&gt; &lt;p class="ArticleText"&gt;Using Microsoft Visual Studio 2005 you can still perform  pre-compilation from the 'Build / Publish Web Site' menu command. Please see  figure 2. &lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="center"&gt;&lt;img src="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Packaging-Publish-Web-Site.jpg" width="549" height="361" /&gt;&lt;br /&gt;Figure 2 &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;h2&gt;SETUP Projects&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-6200307270978827"; /* 728x90, created 5/14/09 */ google_ad_slot = "3045621028"; google_ad_width = 728; google_ad_height = 90; //--&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre-wrap; font-family:-webkit-monospace;font-size:13px;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-6200307270978827"; /* 728x90, created 5/14/09 */ google_ad_slot = "3045621028"; google_ad_width = 728; google_ad_height = 90; //--&gt; &lt;/script&gt; &lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt; &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"   style="  white-space: pre-wrap; font-family:-webkit-monospace;font-size:13px;"&gt;&lt;/script&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;It's always desirable to package your  web applications such that they are easy to deploy on the production server.  Microsoft Visual Studio 2005 gives you this rich packaging option for free ...  Just follow the following instructions ...&lt;/div&gt;&lt;p&gt;&lt;/p&gt; &lt;p class="ArticleText"&gt;First of all you need to know that our target is to create  a package (and MSI file) that contain our web application in a form that can be  later easily deployed on the final production server. &lt;/p&gt; &lt;p class="ArticleText"&gt;Let's start by selecting 'File / New / Project' in  Microsoft Visual Studio 2005. This will present you the famous set of possible  project types from which you will select 'Other Project Types / Setup and  Deployment' then you will select the 'Web Setup  Project' icon from the side to  the right. See figure 3. &lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="center"&gt;&lt;img src="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Packaging-New-Project.jpg" /&gt;&lt;br /&gt;Figure  3 &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p class="ArticleText"&gt;In figure 3, set the appropriate project name and folder  options then click OK. &lt;/p&gt; &lt;p class="ArticleText"&gt;You can always have the same behavior by adding the SETUP  project above to your web application solution instead of creating a new  separate solution. You can achieve this by selecting  'File / Add / New Project'  instead of 'File / New / Project'. This way you will have a self contained web  solution. The 'File / Add / New Project' method is much more recommended. &lt;/p&gt; &lt;p class="ArticleText"&gt;Your setup project will then open as in figure 4 below:  &lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="center"&gt;&lt;img src="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Packaging-WebSetup.jpg" width="651" height="336" /&gt;&lt;br /&gt;Figure 4 &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p class="ArticleText"&gt;You will then need to add your web application files to the  SETUP project we are developing now. This can be achieved by right clicking your  SETUP project name in solution explorer and selecting 'Add / Project Output'.  Please see figure 5. &lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="center"&gt;&lt;img src="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Packaging-Add-Project-Output.jpg" width="324" height="379" /&gt;&lt;br /&gt;Figure 5 &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p class="ArticleText"&gt;To tune the properties of our SETUP project, we will need  to press F4 while it's name is selected in the solution explore. This will bring  the SETUP project's properties window. Several useful properties can be set in  this window: &lt;/p&gt; &lt;table class="ArticleCodeSnippet" border="1" cellspacing="0" bordercolor="#eaeaea" cellpadding="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="183" align="middle"&gt; &lt;div align="center"&gt;&lt;strong&gt;Property&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt; &lt;td align="middle"&gt; &lt;div align="center"&gt;&lt;strong&gt;Purpose &lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="183"&gt;Author, Description, Manufacturer, ManufacturerUrl, ProductName,  Subject, Title, and Version &lt;/td&gt; &lt;td&gt;Use all of these properties to identify / describe your application and  yourself. &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="183"&gt;AddRemoveProgramsIcon &lt;/td&gt; &lt;td&gt;Here you can specify the icon to be displayed beside your application in  Windows Control Panel's Add Remove Programs. &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="183"&gt;DetectNewerInstalledVersion &lt;/td&gt; &lt;td&gt;Specify here whether or not a check is to be performed to determine the  existence of a new version already installed of your web application. &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="183"&gt;RemovePreviousVersions &lt;/td&gt; &lt;td&gt;Specify here whether you need an older version of your web application to be  removed if a newer version is being installed. &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="183"&gt;RestartWWWService &lt;/td&gt; &lt;td&gt;Some web applications requires the Internet Information Service to be  stopped and then restarted after the deployment of the application. Use this  property to control such behavior. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p class="ArticleText"&gt;The last and most important step is to actually build our  SETUP project. This cane be achieved by right clicking the name of our SETUP  project in the solution explorer. It's this specific step that creates the MSI  package / file mentioned above. This is the file you will need to distribute to  your users and this is the file they will use to deploy the web application on  their production server. &lt;/p&gt; &lt;p class="ArticleText"&gt;It's worth mentioning that the actual deployment process  will be some what similar to the SETUP of any typical desktop application (with  some exceptions of course). One of the many similarities is that the web  application after deployment will automatically appear in the 'Add / Remove  Programs' window of Windows Control Panel. &lt;/p&gt; &lt;h2&gt;Production Server Deployment &lt;/h2&gt; &lt;p class="ArticleText"&gt;For your users to deploy your web application they will  just need to double click the MSI file. This will produce something similar to  figure 6: &lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="center"&gt;&lt;img src="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Packaging-Setup-Wizard.jpg" width="503" height="407" /&gt;&lt;br /&gt;Figure 6 &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;h2&gt;Protection and obfuscation of .NET executable files (.exe, .dll,...)&lt;/h2&gt; &lt;p&gt;You must know that every of your .NET products, web application or ASP.NET  custom control, can be easily decompiled. Practically every user can get your  source code by using some free .Net decompiler. If your license doesn't include  source code it is not enough to just exclude source code files from  installation. You need additional protection.&lt;/p&gt; &lt;p&gt;After long analyze, we decided to use &lt;a href="http://www.beansoftware.com/Visit/SpicesNet/" rel="nofollow" target="_top"&gt;Spices.Net&lt;/a&gt; for protection of all products of Bean Software. Even  if you can't afford complete suite, consider at least their Obfuscator. Later, I  discovered &lt;a href="http://www.beansoftware.com/Visit/NetReactor/" rel="nofollow"&gt;.NET Reactor&lt;/a&gt; which also looks good and it is about ten times  cheaper :). You can check Product Comparison link on NetReactor site where it is  compared to some other products, it looks really impressive, and not only in  price issue.&lt;/p&gt; &lt;h2&gt;For further information &lt;/h2&gt; &lt;p class="ArticleText"&gt;Refer to the online copy of Microsoft Developers Network at  &lt;a href="http://msdn.microsoft.com/"&gt;http://msdn.microsoft.com &lt;/a&gt;or use your  own local copy of MSDN..&lt;br /&gt;&lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="center"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;&lt;p class="ArticleText" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="ArticleText" style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="ArticleText" style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-size:48px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-2980137762063961660?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/2980137762063961660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3134941485038447368&amp;postID=2980137762063961660' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/2980137762063961660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/2980137762063961660'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2009/05/how-to-deploy-aspnet-web-application.html' title='How to Deploy ASP.NET Web Application'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-3669441873748614341</id><published>2009-05-14T06:56:00.000-07:00</published><updated>2009-05-14T07:18:44.776-07:00</updated><title type='text'>High Performance ASP.NET - Speeding Up ASP.NET Pages</title><content type='html'>&lt;span style="font-family:arial;font-size:78%;"&gt;article from : &lt;/span&gt;&lt;a href="http://codebetter.com/blogs/david.hayden/archive/2005/08/05/130372.aspx"&gt;&lt;span style="font-family:arial;font-size:78%;"&gt;http://codebetter.com/blogs/david.hayden/archive/2005/08/05/130372.aspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;I have been writing a series of blog posts, which I have coined High Performance ASP.NET Websites Made Easy! There is no rhyme or reason to the order of these posts and certainly can be read in any order:&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2005/07/02/1881.aspx"&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;Developing High Performance and Scalable ASP.NET Websites&lt;/span&gt;&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2005/07/03/1882.aspx"&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;Avoid Chatty Interfaces Between the Tiers in Your ASP.NET Web Application&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2005/07/17/2396.aspx"&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;ASP.NET Page Profiling - Page Tracing - High Performance and Scalable ASP.NET Websites Made Easy&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2005/07/22/2401.aspx"&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;Web Applications: N-Tier vs. N-Layer - Benefits and Trade-Offs&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2005/07/24/2403.aspx"&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;Query Analyzer - Sql Server Database Indexes and Execution Plans&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;The premise behind the ideas presented in these posts are that they must be 1) Dang Near Effortless, 2) Require Very Little Expertise, 3) Leverage Built-In .NET Features or Tools, 4) Easy to Maintain, and 5) Offer Decent Bang For Your Buck&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Speeding Up ASP.NET Pages&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Speeding up ASP.NET Pages can be done in several ways. Below are 3 categories that come to mind and are not complete by any means:&lt;br /&gt;Reduce Page Processing: Eliminating PostBacks, Caching Output, Avoiding Chatty Interfaces, Avoiding Web Controls&lt;br /&gt;Reduce Page Sizes: Limit sizes of ViewState, HTML, JavaScript, and Images&lt;br /&gt;Improve (Faster) Page Rendering: CSS instead of Tables&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;Reduce Page Processing&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;We talked about reducing page processing by short-circuiting the HTTP Pipeline by using ASP.NET Caching.&lt;br /&gt;By caching entire pages or usercontrols, you can eliminate quite a bit of processing done on the page and its controls. In fact, if you do entire page caching, HTTP Headers are sent in the HTTP Response that tells the proxy server and browser it is okay to cache the page, which may keep your web server from being hit by future requests of the same page.&lt;br /&gt;An additional tip to reduce page processing is to avoid web controls all together. Don't use ASP.NET web controls for static information. Stick to the generic HTML controls that we all knew and love before ASP.NET was ever invented.&lt;br /&gt;An old solution packaged with a new name, AJAX, eliminates entire page postbacks, which also reduces page processing. I recommend being careful with this as too much AJAX can be a maintenance headache and is certainly not effortless.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&lt;strong&gt;Reducing Page Sizes&lt;/strong&gt;&lt;br /&gt;A very simple and effective way of increasing the performance of your ASP.NET application is to reduce the page size.&lt;br /&gt;ASP.NET aside for a moment, the less HTML being streamed back to the browser the faster the page. You want to reduce the amount of HTML, the size of images, the size of javascript files, etc.&lt;br /&gt;A note about image sizes. At the Tampa Code Camp, someone thought that changing the width and height attributes of an image caused ASP.NET to reduce the size of the image being streamed to the browser. This isn't the case. The height and width settings on an image are for display purposes only. If you have a 640 x 480 image, the entire image will be streamed to the browser even if you are only displaying 100 x 100. Better to open up your favorite image editor and reduce the image to 100 x 100 for faster performance if it makes sense.&lt;br /&gt;Although I wouldn't recommend it unless absolutely necessary, you can download free tools that will compress / eliminate the white space in HTML and javascript files. This could be a maintenance nightmare. You may want to checkout IIS plugins that will do it for you without physically changing your source files.&lt;br /&gt;Specific to ASP.NET, you want to be careful about the size of your ViewState. Turn-off ViewState on controls if you can, especially on DataGrids, Repeaters, DataLists, and GridViews that tend to be huge if not kept in check. The most effortless idea here is that ASP.NET pages that don't postback to themselves don't require a ViewState. Turn off ViewState altogether on those pages.&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&lt;/div&gt;&lt;/span&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&lt;strong&gt;Improve (Faster) Page Rendering&lt;br /&gt;&lt;/strong&gt;Using CSS instead of tables will cause the browser to render your pages faster. Boy I love tables, but I have been slowly trying to get better and better at using CSS to layout my pages.&lt;br /&gt;I am not an expert on this subject, so I point you to an interesting tutorial on CSS and the benefits of using it over tables:&lt;/span&gt; &lt;span style="font-family:arial;font-size:85%;"&gt;&lt;a href="http://www.hotdesign.com/seybold/index.html" target="_blank"&gt;http://www.hotdesign.com/seybold/index.html&lt;/a&gt;&lt;/span&gt; &lt;p align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Various articles of interest:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&lt;a href="http://www.codeproject.com/html/webspeed.asp" target="_blank"&gt;Ten ways to speed up the download time of your web pages&lt;/a&gt; on CodeProject:&lt;/div&gt;&lt;/li&gt;&lt;/span&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Lay out your pages with CSS, not tables &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Don't use images to display text &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Call up decorative images through CSS &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Use contextual selectors &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Use shorthand CSS properties &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Minimise white space, line returns and comment tags &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Use relative call-ups &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Remove unnecessary META tags and META content &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Put CSS and JavaScript into external documents &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;Use / at the end of directory links&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt06.asp" target="_blank"&gt;Improving ASP.NET Performance on Patterns and Practices&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&lt;a href="http://msdn.microsoft.com/msdnmag/issues/05/01/ASPNETPerformance/default.aspx" target="_blank"&gt;10 Tips for Writing High-Performance Web Applications&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-3669441873748614341?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/3669441873748614341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3134941485038447368&amp;postID=3669441873748614341' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/3669441873748614341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/3669441873748614341'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2009/05/high-performance-aspnet-speeding-up.html' title='High Performance ASP.NET - Speeding Up ASP.NET Pages'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-3492265478557032304</id><published>2009-05-14T06:27:00.000-07:00</published><updated>2009-05-14T06:35:05.456-07:00</updated><title type='text'>If Not Page.IsPostBackUncovering the Mystery</title><content type='html'>&lt;span style="font-family:arial;font-size:85%;"&gt;Many of you have seen this mysterious if/then statement in a lot of the online and book code samples, and you probably have, at one time or another, wondered just what exactly this was all about. This tutorial plans to answer all your questions. There is one basic question that gets asked on &lt;/span&gt;&lt;a href="http://asp.net/forums" target="_blank"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;ASP.Net Forums&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:arial;font-size:85%;"&gt; and &lt;/span&gt;&lt;a href="http://www.aspfriends.com/aspng/index.asp" target="_blank"&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;ASPFriends.com&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:arial;font-size:85%;"&gt; ListServes, over and over, in a several different ways. It all boils down to one answer concerning the IsPostBack Property of the page.&lt;br /&gt;"Why doesn't my DropDownList keep it's Selection?""Why is the selectedindex for my (ASP.Net control) always turning up a -1?"&lt;br /&gt;Fortunately, today, you've come to the right place. You questions will be answered.&lt;br /&gt;Scenario:You put a DropDownList or a ListBox (or just about any ASP.Net control which has multiple items assigned to it) on your web page (inside a form, naturally). Then, at some point, you either populate the list items manually, or bind it to a database table. However, you do it, you get a list of items from which, at some point, the end user can make a choice. Based on that choice, the end user gets more data in return. Most of the basic item population of these controls is done during the initial loading of the page (Page_Load event). That way, the list items are available for choosing once the page is finished loading.&lt;br /&gt;Let's say, then, you also put a button on the page. That way, the end user can choose an item in the list, click the button and get the extended data, based on the selection made. The button's click event would then take the item which was selected and use it in a click event that could then, possibly connect to a database and use the selected item's data to filter a query against a database.&lt;br /&gt;"Of course", you say - "Simple", you say - "No Problem!", you say - even "Why are you bothering me with this drivel?" This is where it all boils down to the mystery for which this tutorial was created. Here it is - your DropDownList was populated with the last names of people at your company. You create a sub procedure for the onclick event of the button to connect to the database and give the end user back all the available data in the table, based on that last name. The SQL statement goes something like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;color:#006600;"&gt;SQL = "Select * from Employees where lastname = '" &amp;amp; DropDownList.SelectedItem.Text &amp;amp; "'"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;However, when you do this, you either get an error, or you get absolutely no results back from the query. You're sure the query is correct - but you can't figure out why this isn't returning any records.&lt;br /&gt;That's because you didn't surround the data population of your control with the basic statement this tutorial is all about:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;color:#009900;"&gt;If not Page.IsPostback then&lt;br /&gt;End If&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;What's happening is that your page is re-loading the data into your server control - it's not responding in any way, to the click event from the button click. First of all, you would never need the server control to re-populate EVERY time the page loaded. That would be terribly inefficient and as you have seen here - it makes making a choice from the control pretty much unuseable.&lt;br /&gt;As I said at the beginning, there are a couple of ways to populate the data items of a server control (DropDownList, ListBox, RadioButtonList, CheckBoxList, etc) - manually and binding the results from a database query to it. It doesn't matter how you populate the data. What DOES matter is that you include the population of the control within the boundaries of this If/Then Statement. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;Two things will happen then. The first thing that will happen, is that, on each subsequent loading of the page, the control doesn't go through the redundant action of re-loading the control. It loads it only once, at the initial page load. Once the page is loaded, the click event from the button (or however you post back) is considered to be a postback. Yes, the page gets reloaded, but, by surrounding your data population with this statement, the page knows that the initial data loading was already done, so it doesn't happen any more, and it gets maintained throughout any subsequent post back. The second, and most rewarding thing that happens is that the selection which was made by the end user is maintained throughout the post back. This is the pay-off - by doing it with the If/Then Page.IsPostBack statement, your selection carries through to your query and the query returns the results you wanted in the first place.&lt;br /&gt;Examples:&lt;br /&gt;&lt;span style="font-family:courier new;color:#006600;"&gt;If Not Page.IsPostBack then&lt;br /&gt;     Dim strConn as string = "server=(local);uid=UID;pwd=PWD;database=Northwind"&lt;br /&gt;     Dim MySQL as string = "Select LastName from Employees"&lt;br /&gt;     Dim MyConn as New SQLConnection(strConn)&lt;br /&gt;     Dim objDR as SQLDataReader&lt;br /&gt;     Dim Cmd as New SQLCommand(MySQL, MyConn)&lt;br /&gt;     MyConn.Open()&lt;br /&gt;     objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)&lt;br /&gt;     DropDownList.DataSource = objDR&lt;br /&gt;     DropDownList.DataBind()&lt;br /&gt;End If&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;By doing it this way, you will always be able to maintain the selection from your DropDownList (or other ASP.Net Control) through the postback events of your pages. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;refernce : &lt;a href="http://72.14.235.132/search?q=cache:oBKOjS9PQs4J:aspnet101.com/aspnet101/tutorials.aspx%3Fid%3D3+asp.net+is+not+postback&amp;amp;cd=1&amp;amp;hl=en&amp;amp;ct=clnk"&gt;http://72.14.235.132/search?q=cache:oBKOjS9PQs4J:aspnet101.com/aspnet101/tutorials.aspx%3Fid%3D3+asp.net+is+not+postback&amp;amp;cd=1&amp;amp;hl=en&amp;amp;ct=clnk&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-3492265478557032304?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/3492265478557032304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3134941485038447368&amp;postID=3492265478557032304' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/3492265478557032304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/3492265478557032304'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2009/05/if-not-pageispostbackuncovering-mystery.html' title='If Not Page.IsPostBackUncovering the Mystery'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-7286770253312410601</id><published>2008-05-25T04:50:00.000-07:00</published><updated>2008-05-25T06:28:53.022-07:00</updated><title type='text'>Error Logging using ASP.NET 2.0</title><content type='html'>Original article location :&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=94"&gt;http://www.dotnetcurry.com/ShowArticle.aspx?ID=94&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;div style="MARGIN: 24pt 0in 0pt"&gt;&lt;b&gt;&lt;span style="font-family:Cambria;font-size:180%;color:#365f91;"&gt;Error Logging using ASP.NET 2.0&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;This article has been republished with a few minor&lt;br /&gt;changes.&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Errors and failures may occur during development and operation of a website. ASP.NET 2.0 provides tracing, instrumentation and error handling mechanisms to detect and fix issues in an application. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;In this article, we will adopt a simple mechanism to log errors and exceptions in our website. We will be using a mechanism where the user will be redirected to a separate page whenever an error is encountered in the application. Simultaneously, the error will get logged in a text file on the server. The error file will be created on a daily basis, whenever the error is encountered. Having said that, let us now see some code.&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;b&gt;Step 1:&lt;/b&gt; Start by creating an Error folder where all errors will be logged. Right click the website &gt; New Folder. Rename the folder to “Error”. Also add a web.config file, if one does not already exist in your site. Right click the website &gt; Add New Item &gt; Web.config. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;b&gt;Step 2:&lt;/b&gt; Now we will create the error&lt;br /&gt;handler code. To do so, right click your website &gt; Add New Item &gt; select Class. Rename the class to ‘ErrHandler.cs’ and click on ‘Add’. When you do so, you will be prompted with a message to place the class in ‘App_Code’ folder. Accept the message to place the class in the 'App_Code' folder. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;b&gt;Step 3:&lt;/b&gt; Now let us add functionality to the ErrHandler class. This class will accept the error message and write the message in a text file. One text file will be created for each day. If the text file already exists, the message will be appended to the text file. If not, a new text file will be created based on today’s date and error message will be written in it.&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;The code will look similar to the following:&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;C#&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:gray;"&gt;///&lt;/span&gt;&lt;span style="font-family:'Courier New';color:green;"&gt; Handles error by accepting the error message &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Displays the page on which the error occured&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static &lt;/span&gt;&lt;span style="color:blue;"&gt;void&lt;/span&gt; WriteError(&lt;span style="color:blue;"&gt;string &lt;/span&gt;errorMessage)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;        try&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;           string&lt;/span&gt; path = &lt;span style="color:#a31515;"&gt;"~/Error/"&lt;/span&gt; + &lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;.Today.ToString(&lt;span style="color:#a31515;"&gt;"dd-mm-yy"&lt;/span&gt;) + &lt;span style="color:#a31515;"&gt;".txt"&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;           if&lt;/span&gt; (!&lt;span style="color:#2b91af;"&gt;File&lt;/span&gt;.Exists(System.Web.&lt;span style="color:#2b91af;"&gt;HttpContext&lt;/span&gt;.Current.Server.MapPath(path)))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#2b91af;"&gt;               File&lt;/span&gt;.Create(System.Web.&lt;span style="color:#2b91af;"&gt;HttpContext&lt;/span&gt;.Current.Server.MapPat(path)).Close();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;           using&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;StreamWriter &lt;/span&gt;w = &lt;span style="color:#2b91af;"&gt;File&lt;/span&gt;.AppendText &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;           System.Web.&lt;span style="color:#2b91af;"&gt;HttpContext&lt;/span&gt;.Current.Server.MapPath(path)))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              w.WriteLine(&lt;span style="color:#a31515;"&gt;"\r\nLog Entry : "&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              w.WriteLine(&lt;span style="color:#a31515;"&gt;"{0}"&lt;/span&gt;,&lt;br /&gt;&lt;span style="color:#2b91af;"&gt;              DateTime&lt;/span&gt;.Now.ToString(&lt;span style="color:#2b91af;"&gt;CultureInfo&lt;/span&gt;.InvariantCulture));&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;              string&lt;/span&gt; err = &lt;span style="color:#a31515;"&gt;"Error in: "&lt;/span&gt; +  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                          System.Web.&lt;span style="color:#2b91af;"&gt;HttpContext&lt;/span&gt;.Current.Request.Url.ToString()&lt;br /&gt;                          +&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt; &lt;span style="color:#a31515;"&gt;". Error Message:"&lt;/span&gt;+ errorMessage;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                          w.WriteLine(err);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              w.WriteLine(&lt;span style="color:#a31515;"&gt;"__________________________"&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              w.Flush();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              w.Close();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;    catch&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;Exception &lt;/span&gt;ex)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;           WriteError(ex.Message);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;VB.NET&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';color:green;"&gt;&lt;span style="font-size:85%;"&gt;''' Handles error by accepting the error message &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:green;"&gt;''' Displays the page on which the error occured&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;Public&lt;/span&gt; &lt;span style="color:blue;"&gt;Shared&lt;/span&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; WriteError(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; errorMessage &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;String&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;    Try&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; path &lt;span style="color:blue;"&gt;As &lt;/span&gt;&lt;span style="color:blue;"&gt;String&lt;/span&gt; = &lt;span style="color:#a31515;"&gt;"~/Error/"&lt;/span&gt; &amp;amp; DateTime.Today.ToString(&lt;span style="color:#a31515;"&gt;"dd-mm-yy"&lt;/span&gt;)&amp;amp; &lt;span style="color:#a31515;"&gt;".txt"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;       If&lt;/span&gt; (&lt;span style="color:blue;"&gt;Not&lt;/span&gt; File.Exists(System.Web.HttpContext.Current.Server.MapPath(path))) t&lt;span style="color:blue;"&gt;hen&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;          File.Create(System.Web.HttpContext.Current.Server.MapPath(path)).Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;       End&lt;/span&gt; &lt;span style="color:blue;"&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;       Using&lt;/span&gt; w &lt;span style="color:blue;"&gt;As&lt;/span&gt; StreamWriter = File.AppendText(System.Web.HttpContext.Current.Server.MapPath(path))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       w.WriteLine(Constants.vbCrLf &amp;amp; &lt;span style="color:#a31515;"&gt;"Log Entry : "&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       w.WriteLine(&lt;span style="color:#a31515;"&gt;"{0}"&lt;/span&gt;,&lt;br /&gt;       DateTime.Now.ToString(CultureInfo.InvariantCulture))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;       Dim&lt;/span&gt; err &lt;span style="color:blue;"&gt;As &lt;/span&gt;&lt;span style="color:blue;"&gt;String&lt;/span&gt; = &lt;span style="color:#a31515;"&gt;"Error in: "&lt;/span&gt; &amp;amp; system.Web.HttpContext.Current.Request.Url.ToString() &amp;amp; &lt;span style="color:#a31515;"&gt;". Error Message:"&lt;/span&gt; &amp;amp; errorMessage&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       w.WriteLine(err)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       w.WriteLine(&lt;span style="color:#a31515;"&gt;"__________________________"&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       w.Flush()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       w.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;    End&lt;/span&gt; &lt;span style="color:blue;"&gt;Using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;    Catch&lt;/span&gt; ex &lt;span style="color:blue;"&gt;As &lt;/span&gt;Exception&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       WriteError(ex.Message)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;    End&lt;/span&gt; &lt;span style="color:blue;"&gt;Try&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;That was our ErrHandler class. We will now see how to use this Error Handler class and handle errors at the page level as well as at the application level.&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Handling errors at Page Level&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;In the Default.aspx, drag and drop a button from the toolbox. Rename this button to btnError and set the Text as ‘Throw Handled Exception’. Here we will throw an exception. Since we have a catch block&lt;br /&gt;defined, the exception will be caught and the error will be logged in the Error folder. Since a text file with today’s date, does not exists, a new text file will be created by the code.&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;The button click handler will look similar to the following:&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;C#&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;void &lt;/span&gt;btnHandled_Click(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender,&lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;     try&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;            throw&lt;/span&gt; &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;Exception&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;"Sample Exception"&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;     catch&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;Exception &lt;/span&gt;ex)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:green;"&gt;        // Log the error to a text file in the Error folder&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#2b91af;"&gt;        ErrHandler&lt;/span&gt;.WriteError(ex.Message);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;VB.NET&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;Protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; btnHandled_Click(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color:blue;"&gt;Handles&lt;/span&gt; btnHandled.Click&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;  Try&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;    Throw&lt;/span&gt; &lt;span style="color:blue;"&gt;New&lt;/span&gt; Exception()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;  Catch&lt;/span&gt; ex &lt;span style="color:blue;"&gt;As&lt;/span&gt; Exception&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:green;"&gt;  ' Log the error to a text file in the Error folder&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    ErrHandler.WriteError(ex.Message)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;  End&lt;/span&gt; &lt;span style="color:blue;"&gt;Try&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Now with the code in place, run the application and click on the button. Since we have handled the error and logged the exception in our code, you will not notice anything when the button is clicked. However, close the application and refresh the Error folder. You will see a new text file created with today’s date. The exception has been logged successfully as shown below. The date and time will differ on your machine.&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;Log Entry : &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;01/11/2008 23:33:46&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;br /&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;Error in:&lt;br /&gt;http://localhost:51087/ErrorHandling/Default.aspx. Error Message:Sample Exception&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;__________________________&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Redirecting users on unhandled errors&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Let us see how to catch unhandled errors and redirect the user to a different page, whenever such an unhandled error occurs at the application level.&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;To catch unhandled errors, do the following. Add a Global.asax file (Right click project &amp;gt; Add New Item &amp;gt; Global.asax). In the Application_Error() method, add the following code:&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;C#&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;void&lt;/span&gt; Application_Error(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:green;"&gt;    // Code that runs when an unhandled error occurs&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#2b91af;"&gt;    Exception&lt;/span&gt; objErr = Server.GetLastError().GetBaseException();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;    string&lt;/span&gt; err = &lt;span style="color:#a31515;"&gt;"Error in: "&lt;/span&gt; + Request.Url.ToString() + &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#a31515;"&gt;". Error Message:"&lt;/span&gt; + objErr.Message.ToString();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:green;"&gt;    // Log the error&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#2b91af;"&gt;    ErrHandler&lt;/span&gt;.WriteError(err);        &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;VB.NET&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;Sub&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; Application_Error(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; EventArgs)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:green;"&gt;' Code that runs when an unhandled error occurs        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; objErr &lt;span style="color:blue;"&gt;As&lt;/span&gt; Exception = Server.GetLastError().GetBaseException()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;    Dim&lt;/span&gt; err &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;String&lt;/span&gt; = &lt;span style="color:#a31515;"&gt;"Error in: "&lt;/span&gt; &amp;amp; Request.Url.ToString() &amp;amp; &lt;span style="color:#a31515;"&gt;". Error Message:"&lt;/span&gt; &amp;amp; objErr.Message.ToString()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:green;"&gt;   ' Log the error&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    ErrHandler.WriteError(err)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;We capture the error using the Server.GetLastError(). Now to redirect users to a different page whenever an unhandled error occurs, open your web.config file and locate the &amp;lt;customErrors&amp;gt;&lt;br /&gt;tag and uncomment it. After removing the comment, the tag will look similar to the following code:&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;&lt;span style="font-size:85%;"&gt;&lt;!--&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';color:green;"&gt;&lt;span style="font-size:85%;"&gt;            The &lt;&gt; section enables configuration &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';color:green;"&gt;&lt;span style="font-size:85%;"&gt;            of what to do if/when an unhandled error occurs &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';color:green;"&gt;&lt;span style="font-size:85%;"&gt;            during the execution of a request. Specifically, &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';color:green;"&gt;&lt;span style="font-size:85%;"&gt;            it enables developers to configure html error pages &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:green;"&gt;            to be displayed in place of a error stack trace.        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;--&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:#a31515;"&gt;&amp;lt;customerrors&lt;/span&gt;&lt;span style="font-family:'Courier New';color:red;"&gt;mode&lt;/span&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;"&lt;span style="color:blue;"&gt;RemoteOnly&lt;/span&gt;"&lt;span style="color:red;"&gt;defaultRedirect&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;GenericErrorPage.htm&lt;/span&gt;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:#a31515;"&gt;&amp;lt;error&lt;/span&gt;&lt;span style="font-family:'Courier New';color:red;"&gt;statusCode&lt;/span&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;"&lt;span style="color:blue;"&gt;403&lt;/span&gt;"&lt;span style="color:red;"&gt;redirect&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;NoAccess.htm&lt;/span&gt;"&lt;span style="color:blue;"&gt; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:#a31515;"&gt;&amp;lt;error&lt;/span&gt;&lt;span style="font-family:'Courier New';color:red;"&gt;statusCode&lt;/span&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;"&lt;span style="color:blue;"&gt;404&lt;/span&gt;"&lt;span style="color:red;"&gt;redirect&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;FileNotFound.htm&lt;/span&gt;"&lt;span style="color:blue;"&gt; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:'Courier New';color:#a31515;"&gt;customErrors&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Now change:&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt; &lt;/span&gt;&lt;span style="font-family:'Courier New';color:red;"&gt;mode&lt;/span&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;"&lt;span style="color:blue;"&gt;RemoteOnly&lt;/span&gt;"to&lt;span style="color:red;"&gt;mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;On&lt;/span&gt;"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:red;"&gt;defaultRedirect&lt;/span&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;"&lt;span style="color:blue;"&gt;GenericErrorPage.htm&lt;/span&gt;"&lt;br /&gt;to &lt;span style="color:red;"&gt;defaultRedirect&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;ErrorPage.aspx&lt;/span&gt;"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;The modified code will now look like this:&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:#a31515;"&gt;&amp;lt;customerrors&lt;/span&gt;&lt;span style="font-family:'Courier New';color:red;"&gt;mode&lt;/span&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;"&lt;span style="color:blue;"&gt;On&lt;/span&gt;"&lt;span style="color:red;"&gt;defaultRedirect&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;ErrorPage.aspx&lt;/span&gt;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:#a31515;"&gt;&amp;lt;error&lt;/span&gt;&lt;span style="font-family:'Courier New';color:red;"&gt;statusCode&lt;/span&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;"&lt;span style="color:blue;"&gt;403&lt;/span&gt;"&lt;span style="color:red;"&gt;redirect&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;NoAccess.htm&lt;/span&gt;"&lt;span style="color:blue;"&gt; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:#a31515;"&gt;&amp;lt;error&lt;/span&gt;&lt;span style="font-family:'Courier New';color:red;"&gt;statusCode&lt;/span&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;"&lt;span style="color:blue;"&gt;404&lt;/span&gt;"&lt;span style="color:red;"&gt;redirect&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;FileNotFound.htm&lt;/span&gt;"&lt;span style="color:blue;"&gt; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;&lt;span style="font-family:Georgia;font-size:100%;color:#000000;"&gt;&lt;&lt;/span&gt;/&lt;/span&gt;&lt;span style="font-family:'Courier New';color:#a31515;"&gt;customErrors&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;This configuration will now redirect the user to an Error page when an error occurs. Let us create this error page and display some message to the user.&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Right Click Project &gt; Add New Item &gt; Create a new ErrorPage.aspx page in the application and display a sample message on the page informing the user that an error has occurred. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;To test our functionality, go back to Default.aspx, add another button and rename it to btnUnhandled and set its Text property to ‘Throw Unhandled Exception’. Here instead of throwing the exception as we did for ‘btn_Error’, we will introduce a ‘Divide By Zero’ exception and not handle it. Observe that there is no try catch block as shown below. So when the error occurs, the user will be redirected to the ‘ErrorPage.aspx’ as a result of the changes made in our web.config file.&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;C#&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; btnHandled_Click(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;         throw&lt;/span&gt; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Exception&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;"Sample Exception"&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;Exception&lt;/span&gt; ex)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:green;"&gt;        // Log the error to a text file in the Error folder&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#2b91af;"&gt;        ErrHandler&lt;/span&gt;.WriteError(ex.Message);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;VB.NET&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';color:blue;"&gt;Protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; btnUnhandled_Click(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color:blue;"&gt;Handles&lt;/span&gt; btnUnhandled.Click&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;   Dim&lt;/span&gt; i &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Integer&lt;/span&gt; = 1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;   Dim&lt;/span&gt; j &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Integer&lt;/span&gt; = 0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   Response.Write(i \ j)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Run the application and click on the ‘Throw Unhandled Exception’ button. You will observe that the user will be automatically redirected to the Error Page and the error will be logged in the Error folder. Well that’s it. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;In this article, we saw how to implement a simple error logging system in our application. Logging errors can be very useful and helps us detect errors during development and operation of a website. ASP.NET also provides some advanced options titled under ‘Health Monitoring’ where the errors can be stored in Sql Server or even emailed to the administrator based on the criticality of it.&lt;/span&gt;&lt;/div&gt;&lt;div style="TEXT-JUSTIFY: inter-ideograph; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;I hope this article was useful and I thank you for viewing it. &lt;/span&gt; &lt;span style="font-family:Verdana;font-size:85%;"&gt;Download the source code of the application over &lt;/span&gt;&lt;a href="http://www.dotnetcurry.com/Uploads/ErrorHandling.zip"&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#0000ff;"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-7286770253312410601?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/7286770253312410601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/7286770253312410601'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2008/05/error-logging-using-aspnet-20.html' title='Error Logging using ASP.NET 2.0'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-1829114575639573731</id><published>2008-05-24T09:27:00.001-07:00</published><updated>2008-05-27T18:50:08.972-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ajax'/><title type='text'>Floating CSS Ajax  Progress Bar</title><content type='html'>&lt;blockquote&gt;&lt;/blockquote&gt;#busylight&lt;br /&gt;{&lt;br /&gt;position: absolute;&lt;br /&gt;z-index: auto;&lt;br /&gt;top: 50%;&lt;br /&gt;left: 25%;&lt;br /&gt;width: 50%;&lt;br /&gt;margin: 0 0 0 0;&lt;br /&gt;padding: 7px 5px 7px 10px;&lt;br /&gt;font: 12px/1.2em "Verdana" , "Lucida Console" , "Courier New" , monospace;&lt;br /&gt;text-align: center;&lt;br /&gt;color: #111;&lt;br /&gt;background-color: #FFFFCC;&lt;br /&gt;border: 1px solid #111;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/* star html hack - IE only */&lt;br /&gt;* html #busylight{&lt;br /&gt;position: absolute;&lt;br /&gt;}&lt;br /&gt;/* a bet on future IEs */&lt;br /&gt;#busylight[id]{&lt;br /&gt;position: fixed;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="style1"&gt;&amp;lt;asp&lt;/span&gt;:&lt;span class="style2"&gt;UpdateProgress &lt;/span&gt;&lt;span class="style3"&gt;ID&lt;/span&gt;="&lt;span class="style4"&gt;UpdateProgress1&lt;/span&gt;" runat="server"&amp;gt;&lt;br /&gt;&amp;lt;ProgressTemplate&amp;gt;&lt;br /&gt;&amp;lt;div&amp;gt;&lt;br /&gt;&amp;lt;table ID="busylight" border="0" cellpadding="0" cellspacing="0"&amp;gt;&lt;br /&gt;&amp;lt;tr valign="top"&amp;gt; &amp;lt;td align="center" style=""&amp;gt;&lt;br /&gt;&amp;lt;img alt="busy" src="Images/ajax-loader.gif" /&amp;gt; Please wait..................&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt; &amp;lt;/ProgressTemplate&amp;gt;&lt;br /&gt;&amp;lt;/asp:UpdateProgress&amp;gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-1829114575639573731?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/1829114575639573731/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3134941485038447368&amp;postID=1829114575639573731' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/1829114575639573731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/1829114575639573731'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2008/05/floating-css-ajax-progress-bar.html' title='Floating CSS Ajax  Progress Bar'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-2990837263361571756</id><published>2008-05-23T09:43:00.001-07:00</published><updated>2008-05-23T09:43:36.205-07:00</updated><title type='text'>Ajax Master Detail Tab</title><content type='html'>http://channel9.msdn.com/Screencasts/309889_AjaxMasterDetailsTabs.wmvFile :&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.federaldeveloper.com/Shared%20Documents/Screencasts%20by%20Marc%20Schweigert/AjaxMasterDetailsTabs.zip"&gt;http://www.federaldeveloper.com/Shared%20Documents/Screencasts%20by%20Marc%20Schweigert/AjaxMasterDetailsTabs.zip&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-2990837263361571756?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/2990837263361571756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3134941485038447368&amp;postID=2990837263361571756' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/2990837263361571756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/2990837263361571756'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2008/05/ajax-master-detail-tab.html' title='Ajax Master Detail Tab'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-3548846956273322065</id><published>2008-05-23T09:39:00.001-07:00</published><updated>2008-05-23T09:39:58.929-07:00</updated><title type='text'>ASP.NET AJAX CascadingDropDown with Visual Basic and a Database</title><content type='html'>Using ASP.NET AJAX CascadingDropDown with Visual Basic and a Database Get sample from &lt;a href="http://www.nerdliness.com/article/2008/02/15/using-asp-net-ajax-cascadingdropdown-visual-basic-and-database"&gt;http://www.nerdliness.com/article/2008/02/15/using-asp-net-ajax-cascadingdropdown-visual-basic-and-database&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-3548846956273322065?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/3548846956273322065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3134941485038447368&amp;postID=3548846956273322065' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/3548846956273322065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/3548846956273322065'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2008/05/aspnet-ajax-cascadingdropdown-with.html' title='ASP.NET AJAX CascadingDropDown with Visual Basic and a Database'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3134941485038447368.post-386126165688692662</id><published>2008-05-23T09:34:00.000-07:00</published><updated>2008-05-23T09:35:15.924-07:00</updated><title type='text'>Code Converter for .NET 2.0 - Online, as well as Offline</title><content type='html'>&lt;img alt="[CodeConverter.png]" src="http://1.bp.blogspot.com/_33Xkd2g_vO8/SDbvXnXm-yI/AAAAAAAAACQ/7v26HZ9UX9g/s1600/CodeConverter.png" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;This code converter behaves exactly the same way as the &lt;a href="http://chrison.net/ct.ashx?id=93601f8b-3029-449b-b5a6-39048758be9b&amp;amp;url=http%3a%2f%2fdeveloper.sharpdevelop.net%2fcodeconvert.net%2fConvert.aspx"&gt;online converter&lt;/a&gt;. To get you started, the following download contains both the executable (in the bin/release folder) as well as the source code for the application shown in this screenshot. Have fun, and please don't forget to &lt;a href="http://chrison.net/ct.ashx?id=93601f8b-3029-449b-b5a6-39048758be9b&amp;amp;url=http%3a%2f%2fcommunity.sharpdevelop.net%2fforums%2f19%2fShowForum.aspx"&gt;report conversion errors&lt;/a&gt; so we can improve the underlying &lt;a href="http://chrison.net/ct.ashx?id=93601f8b-3029-449b-b5a6-39048758be9b&amp;amp;url=http%3a%2f%2flaputa.sharpdevelop.net%2fNRefactoryTutorialVideo.aspx"&gt;NRefactory&lt;/a&gt;!&lt;br /&gt;&lt;a href="http://chrison.net/ct.ashx?id=93601f8b-3029-449b-b5a6-39048758be9b&amp;amp;url=http%3a%2f%2fchrison.net%2fcontent%2fbinary%2fCodeConvertServiceClient.zip"&gt;CodeConvertServiceClient.zip (38.57 KB)&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3134941485038447368-386126165688692662?l=my-ajax.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my-ajax.blogspot.com/feeds/386126165688692662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3134941485038447368&amp;postID=386126165688692662' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/386126165688692662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3134941485038447368/posts/default/386126165688692662'/><link rel='alternate' type='text/html' href='http://my-ajax.blogspot.com/2008/05/code-converter-for-net-20-online-as.html' title='Code Converter for .NET 2.0 - Online, as well as Offline'/><author><name>fardzlei</name><uri>http://www.blogger.com/profile/17237660574980616426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_33Xkd2g_vO8/SDbvXnXm-yI/AAAAAAAAACQ/7v26HZ9UX9g/s72-c/CodeConverter.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
