<?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:blogger='http://schemas.google.com/blogger/2008' 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-5353130915959995656</id><updated>2026-05-08T16:19:13.892+05:30</updated><title type='text'>ASP.NET WITH C# ERRORS TROUBLE SHOOTING</title><subtitle type='html'>These  are some of the errors I faced and solved</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>86</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-6327639452636197010</id><published>2012-12-17T19:04:00.001+05:30</published><updated>2012-12-17T19:04:19.608+05:30</updated><title type='text'>About Session ID in Asp.Net </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;background-color: white; color: #ff0099; font-family: Arial, serif; font-size: 22px; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;&quot;&gt;
Session ID in ASP.Net&lt;/h1&gt;
&lt;div class=&quot;entry-meta&quot; style=&quot;background-color: white; color: #666666; font-family: Arial, serif; font-size: 11px; margin: 10px 0px 6px; padding: 0px;&quot;&gt;
&lt;span class=&quot;meta-author&quot;&gt;&lt;/span&gt;&lt;span class=&quot;meta-date&quot;&gt;&lt;/span&gt;&lt;span class=&quot;meta-cat&quot;&gt;&lt;img src=&quot;http://img442.imageshack.us/img442/7683/icongallery.gif&quot; style=&quot;border: 0px; max-width: 600px;&quot; /&gt;&amp;nbsp;Session ID in ASP.Net&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;meta-sep&quot; style=&quot;color: #999999; margin: 0px 3px;&quot;&gt;|&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;meta-comments&quot;&gt;1 comments&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;entry entry-content&quot; style=&quot;background-color: white; color: #333333; font-family: Arial, serif; font-size: 12px; line-height: 12.666666984558105px; margin: 0px; padding: 0px;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijFAUBnatfW06K_OpI2DnT8RnQdprYPvKUrf-DtfbDXvetiqyR7gl-Dd1G4Wlw_ess1XhvI6ALYDFc9pvCO9-Hf3km1GkBB7xwRCp80DdB-eaPDPBSdun9B8-P4VDbWX3oFOX35afsLaHO/s1600-h/SessionID.jpg&quot; style=&quot;color: #004276; font-family: arial; text-decoration: initial;&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;142&quot; id=&quot;BLOGGER_PHOTO_ID_5332288842319750578&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijFAUBnatfW06K_OpI2DnT8RnQdprYPvKUrf-DtfbDXvetiqyR7gl-Dd1G4Wlw_ess1XhvI6ALYDFc9pvCO9-Hf3km1GkBB7xwRCp80DdB-eaPDPBSdun9B8-P4VDbWX3oFOX35afsLaHO/s400/SessionID.jpg&quot; style=&quot;border: 0px; display: block; height: 114px; margin: 0px auto 10px; max-width: 600px; text-align: center; width: 320px;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;Asp.Net use 120 bit identifier to track each session. This is secure enough and can&#39;t be reverse engineered. When client communicate&amp;nbsp;&lt;span class=&quot;IL_AD&quot; id=&quot;IL_AD5&quot; style=&quot;background-attachment: scroll !important; background-color: transparent !important; background-image: none !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding: 0px 0px 1px !important; position: static; text-decoration: underline !important;&quot;&gt;with server&lt;/span&gt;, only session id is transmitted, between them. When client request for data, ASP.NET looks on to session ID and retrieves corresponding data. This is done in following steps,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;* Client hits web site and some information is stored in session.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;* Server creates a unique session ID for that clients and stored in Session State Provider .&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;* Again client request For some information with that unique session ID from Server.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;* Server,looks on Session Providers, and retrieve the serialized data from state server and type cast the object.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/6327639452636197010/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/about-session-id-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/6327639452636197010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/6327639452636197010'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/about-session-id-in-aspnet.html' title='About Session ID in Asp.Net '/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijFAUBnatfW06K_OpI2DnT8RnQdprYPvKUrf-DtfbDXvetiqyR7gl-Dd1G4Wlw_ess1XhvI6ALYDFc9pvCO9-Hf3km1GkBB7xwRCp80DdB-eaPDPBSdun9B8-P4VDbWX3oFOX35afsLaHO/s72-c/SessionID.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-5647234551025958279</id><published>2012-12-17T18:56:00.002+05:30</published><updated>2012-12-17T18:56:45.297+05:30</updated><title type='text'>Difference between ViewBag, ViewDate and TempData in MVC</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
ASP.NET MVC offers us three options ViewData, VieBag and TempData for passing data from controller to view and in next request. ViewData and ViewBag are almost similar and TempData performs additional responsibility. Lets discuss or get key points on those three objects:&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Similarities between ViewBag &amp;amp; ViewData :&lt;/div&gt;
&lt;ol style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;Helps to maintain data when you move from controller to view.&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;Used to pass data from controller to corresponding view.&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;Short life means value becomes null when redirection occurs. This is because their goal is to provide a way to communicate between controllers and views. It’s a communication mechanism within the server call.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Difference between ViewBag &amp;amp; ViewData:&lt;/div&gt;
&lt;ol style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;ViewData is a dictionary of objects that is derived from ViewDataDictionary class and accessible using strings as keys.&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;ViewData requires typecasting for complex data type and check for null values to avoid error.&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;ViewBag doesn’t require typecasting for complex data type.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
ViewBag &amp;amp; ViewData Example:&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain0&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg0&quot; preid=&quot;0&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse0&quot; preid=&quot;0&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/476967/WhatplusisplusViewData-2cplusViewBagplusandplusTem#&quot; preid=&quot;0&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre0&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; ActionResult Index()
{
    ViewBag.Name = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Monjurul Habib&quot;&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt; View();
}
&lt;/pre&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain1&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg1&quot; preid=&quot;1&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse1&quot; preid=&quot;1&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/476967/WhatplusisplusViewData-2cplusViewBagplusandplusTem#&quot; preid=&quot;1&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre1&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; ActionResult Index()
{
    ViewData[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Name&quot;&lt;/span&gt;] = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Monjurul Habib&quot;&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt; View();
} 
&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
In View:&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain2&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg2&quot; preid=&quot;2&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse2&quot; preid=&quot;2&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/476967/WhatplusisplusViewData-2cplusViewBagplusandplusTem#&quot; preid=&quot;2&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre2&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;@ViewBag.Name 
@ViewData[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Name&quot;&lt;/span&gt;] 
&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
TempData:&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
TempData is also a dictionary derived from TempDataDictionary class and stored in short lives session and it is a string key and object value. The difference is that the life cycle of the object. TempData keep the information for the time of an HTTP Request. This mean only from one page to another. This also work with a 302/303 redirection because it’s in the same HTTP Request. Helps to maintain data when you move from one controller to other controller or from one action to other action. In other words when you redirect, “Tempdata” helps to maintain data between those redirects. It internally uses session variables. Temp data use during the current and subsequent request only means it is use when you are sure that next request will be redirecting to next view. It requires typecasting for complex data type and check for null values to avoid error. generally used to store only one time messages like error messages, validation messages.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain3&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg3&quot; preid=&quot;3&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse3&quot; preid=&quot;3&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/476967/WhatplusisplusViewData-2cplusViewBagplusandplusTem#&quot; preid=&quot;3&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre3&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; ActionResult Index()
{
  &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; model = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; Review()
            {
                Body = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Start&quot;&lt;/span&gt;,
                Rating=5
            };
    TempData[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;ModelName&quot;&lt;/span&gt;] = model;
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt; RedirectToAction(&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;About&quot;&lt;/span&gt;);
}
&amp;lt;pre&amp;gt;&amp;lt;pre lang=&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;cs&quot;&lt;/span&gt;&amp;gt;public ActionResult About()
{
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; model= TempData[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;ModelName&quot;&lt;/span&gt;];
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt; View(model);
}
&lt;/pre&gt;
&lt;span style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;The last mechanism is the Session which work like the ViewData, like a Dictionary that take a string for key and object for value. This one is stored into the client Cookie and can be used for a much more long time. It also need more verification to never have any confidential information. Regarding ViewData or ViewBag you should use it intelligently for application performance. Because each action goes through the whole life cycle of regular asp.net mvc request. You can use ViewData/ViewBag in your child action but be careful that you are not using it to populate the unrelated data which can pollute your controller&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/5647234551025958279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/difference-between-viewbag-viewdate-and.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5647234551025958279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5647234551025958279'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/difference-between-viewbag-viewdate-and.html' title='Difference between ViewBag, ViewDate and TempData in MVC'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-8352814736884776696</id><published>2012-12-17T18:35:00.001+05:30</published><updated>2012-12-17T18:35:01.644+05:30</updated><title type='text'>SQL Server Index Column Order - Does it Matter?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h2 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14pt;&quot;&gt;
Problem&lt;/h2&gt;
&lt;div style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot;&gt;
There is a delicate balance on performance when it comes to setting up the indexes on a table. Too many indexes and your INSERT / UPDATE / DELETE performance will suffer, but not enough indexing will impact your SELECT performance. This tip will look at the order of the columns in your index and how this order impacts&amp;nbsp;&lt;a href=&quot;http://www.mssqltips.com/sqlservertip/1873/how-to-read-sql-server-graphical-query-execution-plans/&quot;&gt;query plans&lt;/a&gt;&amp;nbsp;and performance.&lt;/div&gt;
&lt;h2 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14pt;&quot;&gt;
Solution&lt;/h2&gt;
&lt;h3 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;&quot;&gt;
Sample SQL Server Table and Data Population&lt;/h3&gt;
&lt;div style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot;&gt;
For this example we will setup two sample tables and populate each of the tables with data.&amp;nbsp;Here is the code:&lt;/div&gt;
&lt;div class=&quot;codediv&quot; style=&quot;background-color: #ffffe1; border-collapse: separate; border-spacing: 5px; border: 1px solid rgb(170, 170, 170); font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 9pt; overflow: hidden; padding: 4px; width: 750px;&quot;&gt;
&lt;pre&gt;-- Table creation logic
CREATE TABLE [dbo].[TABLE1] 
([col1] [int] NOT NULL,[col2] [int] NULL,[col3] [int] NULL,[col4] [varchar](50) NULL)
GO
CREATE TABLE [dbo].[TABLE2] 
([col1] [int] NOT NULL,[col2] [int] NULL,[col3] [int] NULL,[col4] [varchar](50) NULL)
GO
ALTER TABLE dbo.TABLE1 ADD CONSTRAINT PK_TABLE1 PRIMARY KEY CLUSTERED (col1) 
GO
ALTER TABLE dbo.TABLE2 ADD CONSTRAINT PK_TABLE2 PRIMARY KEY CLUSTERED (col1)
GO
-- Populate tables
DECLARE @val INT
SELECT @val=1
WHILE @val &amp;lt; 1000
BEGIN  
   INSERT INTO dbo.Table1(col1, col2, col3, col4) VALUES(@val,@val,@val,&#39;TEST&#39;)
   INSERT INTO dbo.Table2(col1, col2, col3, col4) VALUES(@val,@val,@val,&#39;TEST&#39;)
   SELECT @val=@val+1
END
GO
-- Create multi-column index on table1
CREATE NONCLUSTERED INDEX IX_TABLE1_col2col3 ON dbo.TABLE1 (col2,col3)
  WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, 
        ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) 
  ON [PRIMARY]
GO&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot;&gt;
Before we run the following commands include the actual execution plan (Ctrl + M) and also turn on Statistics IO by running &quot;SET STATISTICS IO ON&quot; in the query window.&lt;/div&gt;
&lt;h3 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;&quot;&gt;
Single Table Query Example&lt;/h3&gt;
&lt;div style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot;&gt;
For our first example let&#39;s take a look at a simple query with one column in the WHERE clause. The first query uses the second column (col3) of the index in the WHERE clause and the second query uses the first column (col2) of the index in the WHERE clause. Note we are using &quot;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms187762.aspx&quot; target=&quot;_blank&quot;&gt;DBCC DROPCLEANBUFFERS&lt;/a&gt;&quot; to ensure the cache is empty before each query is executed. Here is the code:&lt;/div&gt;
&lt;div class=&quot;codediv&quot; style=&quot;background-color: #ffffe1; border-collapse: separate; border-spacing: 5px; border: 1px solid rgb(170, 170, 170); font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 9pt; overflow: hidden; padding: 4px; width: 750px;&quot;&gt;
&lt;pre&gt;DBCC DROPCLEANBUFFERS
GO
SELECT * FROM dbo.TABLE1 WHERE col3=88
GO
DBCC DROPCLEANBUFFERS
GO
SELECT * FROM dbo.TABLE1 WHERE col2=88
GO&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot;&gt;
Before running the command turn on the execution plan.&amp;nbsp; Looking at the&amp;nbsp;&lt;a href=&quot;http://www.mssqltips.com/sqlservertip/1873/how-to-read-sql-server-graphical-query-execution-plans/&quot;&gt;explain plans&lt;/a&gt;&amp;nbsp;for these two queries we can see that the query that uses the second column (col3) of the index in the WHERE clause is performing an index scan on PK_TABLE1 and not even using the index we created on the column. The second query which has the first column (col2) of the index in the WHERE clause is performing a seek on the index we created and even on this small table uses fewer resources, 6 reads as compared to 4 reads, to execute this query. You can probably guess that this increase in performance only increases as the table becomes larger.&lt;/div&gt;
&lt;div class=&quot;imageborder&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; text-align: center;&quot;&gt;
&lt;img alt=&quot;Single table query using second column of index&quot; height=&quot;121&quot; src=&quot;http://www.mssqltips.com/tipimages2/2718_Single_Table_Second_Column.gif&quot; style=&quot;border: 0px;&quot; width=&quot;416&quot; /&gt;&lt;/div&gt;
&lt;br style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;div class=&quot;imageborder&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; text-align: center;&quot;&gt;
&lt;img alt=&quot;Single table query using first column of index&quot; height=&quot;211&quot; src=&quot;http://www.mssqltips.com/tipimages2/2718_Single_Table_First_Column.gif&quot; style=&quot;border: 0px;&quot; width=&quot;457&quot; /&gt;&lt;/div&gt;
&lt;br style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;div class=&quot;codediv&quot; style=&quot;background-color: #ffffe1; border-collapse: separate; border-spacing: 5px; border: 1px solid rgb(170, 170, 170); font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 9pt; overflow: hidden; padding: 4px; width: 750px;&quot;&gt;
-- query 1&lt;br /&gt;Table &#39;TABLE1&#39;. Scan count 1, logical reads 6, physical reads 0&lt;br /&gt;-- query 2&lt;br /&gt;Table &#39;TABLE1&#39;. Scan count 1, logical reads 4, physical reads 0&lt;/div&gt;
&lt;h3 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;&quot;&gt;
Two Table Join Query Example&lt;/h3&gt;
&lt;div style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot;&gt;
For our next example let&#39;s take a look a query that has the same WHERE clause but also adds an inner join to another table. We will again have two queries. The first query has the second column (col3) of the index in the WHERE clause and the first column (col2) of the index is used to join the table. The second query has the first column (col2) of the index in the WHERE clause and second column (col3) of the index is used to join the table. Again we are using &quot;DBCC DROPCLEANBUFFERS&quot; to ensure the cache is empty before each query is executed. Here is the code:&lt;/div&gt;
&lt;div class=&quot;codediv&quot; style=&quot;background-color: #ffffe1; border-collapse: separate; border-spacing: 5px; border: 1px solid rgb(170, 170, 170); font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 9pt; overflow: hidden; padding: 4px; width: 750px;&quot;&gt;
&lt;pre&gt;DBCC DROPCLEANBUFFERS
GO
SELECT * 
  FROM dbo.TABLE1 INNER JOIN 
       dbo.TABLE2 ON dbo.TABLE1.col2 = dbo.TABLE2.col1
 WHERE dbo.TABLE1.col3=255       
GO
DBCC DROPCLEANBUFFERS
GO
SELECT * 
  FROM dbo.TABLE1 INNER JOIN 
       dbo.TABLE2 ON dbo.TABLE1.col3 = dbo.TABLE2.col1
 WHERE dbo.TABLE1.col2=255       
GO&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot;&gt;
Looking at the&amp;nbsp;&lt;a href=&quot;http://www.mssqltips.com/sqlservertip/1873/how-to-read-sql-server-graphical-query-execution-plans/&quot;&gt;explain plans&lt;/a&gt;&amp;nbsp;for these two queries we can see that when the column that the tables are joined on appears first in the index the query does an index scan of this table (as it did in the first example). The second query which has the first column of the index in the WHERE clause is performing a seek on the index we created. Again this second query uses fewer resources to complete, 6 reads as compared to the 8 reads required by the first query doing the scan. This increase in performance will also become greater as more data is added to these tables, as was the case in the previous example.&lt;/div&gt;
&lt;div class=&quot;imageborder&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; text-align: center;&quot;&gt;
&lt;img alt=&quot;Table join using second column of index&quot; height=&quot;230&quot; src=&quot;http://www.mssqltips.com/tipimages2/2718_TableJoin_Second_Column.gif&quot; style=&quot;border: 0px;&quot; width=&quot;520&quot; /&gt;&lt;/div&gt;
&lt;br style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;div class=&quot;imageborder&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; text-align: center;&quot;&gt;
&lt;img alt=&quot;Table join using first column of index&quot; height=&quot;300&quot; src=&quot;http://www.mssqltips.com/tipimages2/2718_TableJoin_First_Column.gif&quot; style=&quot;border: 0px;&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;br style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;div class=&quot;codediv&quot; style=&quot;background-color: #ffffe1; border-collapse: separate; border-spacing: 5px; border: 1px solid rgb(170, 170, 170); font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 9pt; overflow: hidden; padding: 4px; width: 750px;&quot;&gt;
-- query 1&lt;br /&gt;Table &#39;TABLE2&#39;. Scan count 0, logical reads 2, physical reads 0&lt;br /&gt;Table &#39;TABLE1&#39;. Scan count 1, logical reads 6, physical reads 0&lt;br /&gt;&lt;br /&gt;-- query 2&lt;br /&gt;Table &#39;TABLE2&#39;. Scan count 0, logical reads 2, physical reads 0&lt;br /&gt;Table &#39;TABLE1&#39;. Scan count 1, logical reads 4, physical reads 0&lt;/div&gt;
&lt;h3 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;&quot;&gt;
Summary&lt;/h3&gt;
&lt;div style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;&quot;&gt;
You can see from these simple examples above that the ordering of the columns in your index does have an impact on how any queries against the tables will behave. A best practice that I&#39;ve followed that has been quite helpful when creating indexes is to make sure you are always working with the smallest result set possible. This means that your indexes should start with any columns in your WHERE clause followed by the columns in your JOIN condition. A couple more steps that also help query performance is to include any columns in an ORDER BY clause as well as making the index a covering index by including the columns in your SELECT list, this will remove the lookup step to retrieve data. One thing I mentioned earlier that I want to re-interate here is that by adding more indexes to tables as well as adding more columns to an existing index it will require more resources to update these indexes when inserting, updating and deleting data, so finding a balance is important.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/8352814736884776696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/sql-server-index-column-order-does-it.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/8352814736884776696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/8352814736884776696'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/sql-server-index-column-order-does-it.html' title='SQL Server Index Column Order - Does it Matter?'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-8273062885998926320</id><published>2012-12-17T17:50:00.001+05:30</published><updated>2012-12-17T17:50:38.584+05:30</updated><title type='text'>Exception Handling in ASP.NET MVC</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: white; color: #666666; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 18px; font-weight: normal;&quot;&gt;
Index&lt;/h3&gt;
&lt;ol style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#intro&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#handleerror&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;HandleErrorAttribute&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#limitations&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Limitations of HandleError&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#handleerrorvsapperror&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;HandleError vs Application_Error&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#extendinghandleerror&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Extending HandleError&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#returningviews&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Returning views from Application_Error&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#elmah&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;ELMAH&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#summary&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;intro&quot; style=&quot;background-color: white; color: #666666; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 18px; font-weight: normal;&quot;&gt;
Introduction&lt;/h3&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Exception handling is a serious matter in any application, whether it&#39;s web or desktop. Implementing a proper exception handling is important in any application. In most cases once we catch the exception we have to log the exception details to database or text file and show a friendly message to the user.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
In ASP.NET applications, error handling is done mostly in two ways: at local level using try-catch blocks and at global level using application events. ASP.NET MVC comes with some built-in support for exception handling through&lt;em style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;exception filters&lt;/em&gt;. The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;is the default built-in exception filter. Unfortunately, the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter not gives a complete answer to the exception handling problem and that makes us to still rely on the&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
In this article, we will learn about the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter and discuss about the different exception handling mechanisms that will fit to an MVC application.&lt;/div&gt;
&lt;h3 id=&quot;handleerror&quot; style=&quot;background-color: white; color: #666666; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 18px; font-weight: normal;&quot;&gt;
HandleErrorAttribute&lt;/h3&gt;
&lt;h4 style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 16px;&quot;&gt;
Exception filters&lt;/h4&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
The exception filters are attributes that can be applied over an action or a controller or even at a global level. When you apply the filter at the global level then it will handle the exceptions raised by all the actions of all the controllers. The exception filters not only catches the exceptions that are raised by the actions but also the ones that are raised by the action filters that are applied over that action.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
All the exception filters implements the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;IExceptionFilter&lt;/code&gt;&amp;nbsp;interface. The Listing 1. shows the definition of this interface. The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;IExceptionFilter&lt;/code&gt;&amp;nbsp;contains a single method called&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;OnException&lt;/code&gt;&amp;nbsp;which will be called whenever an exception occurs. The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;ExceptionContext&lt;/code&gt;&amp;nbsp;parameter which derives from&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;ControllerContext&lt;/code&gt;&amp;nbsp;provides access to controller, route data and&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HttpContext&lt;/code&gt;.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain0&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg0&quot; preid=&quot;0&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse0&quot; preid=&quot;0&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;0&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre0&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;interface&lt;/span&gt; IExceptionFilter
{
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;void&lt;/span&gt; OnException(ExceptionContext filterContext);
}&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 1. IExceptionFilter definition&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleErrorAttribute&lt;/code&gt;&amp;nbsp;is the default implementation of the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;IExceptionFilter&lt;/code&gt;. When you create a MVC application you will see the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleErrorAttribute&lt;/code&gt;&amp;nbsp;is added to the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;GlobalFiltersCollection&lt;/code&gt;&amp;nbsp;in the&lt;em style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;Global.asax.cs&lt;/em&gt;.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain1&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg1&quot; preid=&quot;1&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse1&quot; preid=&quot;1&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;1&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre1&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;void&lt;/span&gt; RegisterGlobalFilters(GlobalFiltersCollection filters)
{
    filters.Add(&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; HandleErrorAttribute());
}&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 2. Registering HandleErrorAttribute to GlobalFiltersCollection&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 16px;&quot;&gt;
What the HandleError filter does?&lt;/h4&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter handles the exceptions that are raised by the controller actions, filters and views, it returns a custom view named&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Error&lt;/code&gt;&amp;nbsp;which is placed in the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Shared&lt;/code&gt;&amp;nbsp;folder. The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter works only if the&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;customErrors&amp;gt;&lt;/code&gt;&amp;nbsp;section is turned on in&amp;nbsp;&lt;em style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;web.config&lt;/em&gt;.&lt;/div&gt;
&lt;div class=&quot;para-box&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px; margin: 0px; padding: 0px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter handle exceptions only if the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;customErrors&amp;gt;&lt;/code&gt;&amp;nbsp;is turned on in&amp;nbsp;&lt;em style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;web.config&lt;/em&gt;.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 16px;&quot;&gt;
Error View&lt;/h4&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
The Error view that is created by default contains the following HTML:&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain2&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg2&quot; preid=&quot;2&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse2&quot; preid=&quot;2&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;2&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre2&quot; lang=&quot;xml&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;@{
   Layout = null;
}

&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;!DOCTYPE&lt;/span&gt; &lt;span class=&quot;code-attribute&quot; style=&quot;border: 0px; color: red; margin: 0px; padding: 0px;&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;meta&lt;/span&gt; &lt;span class=&quot;code-attribute&quot; style=&quot;border: 0px; color: red; margin: 0px; padding: 0px;&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;viewport&quot;&lt;/span&gt; &lt;span class=&quot;code-attribute&quot; style=&quot;border: 0px; color: red; margin: 0px; padding: 0px;&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;width=device-width&quot;&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;Error&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
       Sorry, an error occurred while processing your request.
   &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 3. Error View&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
It contains nothing other than a simple text message. The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Layout&lt;/code&gt;&amp;nbsp;property is set to null so that the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Error&lt;/code&gt;&amp;nbsp;view doesn&#39;t inherits the application&#39;s style.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 16px;&quot;&gt;
Accessing the exception details in Error view&lt;/h4&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
In some cases, we have to access the exception information from the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Error&lt;/code&gt;&amp;nbsp;view. The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter not only just returns the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Error&lt;/code&gt;&amp;nbsp;view but it also creates and passes the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleErrorInfo&lt;/code&gt;&amp;nbsp;model to the view. The&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleErrorInfo&lt;/code&gt;&amp;nbsp;model contains the details about the exception and the names of the controller and action that caused the exception.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Here is the definition of the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleErrorInfo&lt;/code&gt;.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain3&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg3&quot; preid=&quot;3&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse3&quot; preid=&quot;3&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;3&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre3&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;class&lt;/span&gt; HandleErrorInfo
{   
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; HandleErrorInfo(Exception exception, &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt; controllerName, 
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt; actionName);

    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt; ActionName { &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;get&lt;/span&gt;; }

    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt; ControllerName { &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;get&lt;/span&gt;; }

    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; Exception Exception { &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;get&lt;/span&gt;; }
}&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 4. HandleErrorInfo model&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Though it&#39;s not necessary, let&#39;s strongly type the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Error&lt;/code&gt;&amp;nbsp;view to the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleErrorInfo&lt;/code&gt;&amp;nbsp;model.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain4&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg4&quot; preid=&quot;4&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse4&quot; preid=&quot;4&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;4&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre4&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;@model System.Web.Mvc.HandleErrorInfo&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 5. Strongly typing Error view to HandleErrorInfo model&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
We can easily show the exception and other information by accessing the model through the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Model&lt;/code&gt;&amp;nbsp;property.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain5&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg5&quot; preid=&quot;5&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse5&quot; preid=&quot;5&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;5&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre5&quot; lang=&quot;xml&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;Exception details&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
    Controller: @Model.ControllerName &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;
    Action: @Model.ActionName
    Exception: @Model.Exception
&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot; style=&quot;border: 0px; color: maroon; margin: 0px; padding: 0px;&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 6. Displaying exception details in Error view&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 16px;&quot;&gt;
Returning different views for different exceptions&lt;/h4&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
We can return different views from the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter. For ex. if you want to return one view for database exceptions and another view for application exceptions, you could easily do that by specifying the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;View&lt;/code&gt;&amp;nbsp;and&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Exception&lt;/code&gt;&amp;nbsp;properties as shown in the below listing.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain6&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg6&quot; preid=&quot;6&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse6&quot; preid=&quot;6&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;6&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre6&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;[HandleError(Exception = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;typeof&lt;/span&gt;(DbException), View = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;DatabaseError&quot;&lt;/span&gt;)]
[HandleError(Exception = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;typeof&lt;/span&gt;(AppException), View = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;ApplicationError&quot;&lt;/span&gt;)]
&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;class&lt;/span&gt; ProductController
{
    
}&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 7. Setting View and Exception properties&lt;/div&gt;
&lt;div class=&quot;para-box&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px; margin: 0px; padding: 0px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleErrorAttribute&lt;/code&gt;&amp;nbsp;can be applied multiple times over a controller or action or at global level.&lt;/div&gt;
&lt;h3 id=&quot;limitations&quot; style=&quot;background-color: white; color: #666666; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 18px; font-weight: normal;&quot;&gt;
Limitations of HandleError&lt;/h3&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter has some limitations by the way.&lt;/div&gt;
&lt;ol style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;Not support to log the exceptions&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;Doesn&#39;t catch HTTP exceptions other than 500&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;Doesn&#39;t catch exceptions that are raised outside controllers&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;Return error view even for exceptions occurred in AJAX calls&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Let us see one by one!&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 16px;&quot;&gt;
1. Not support to log the exceptions&lt;/h4&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Logging is very important in error handling and even simple applications get much benefit by logging the errors to a text file or database. The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter suppresses the exceptions once they are handled and all it does is showing a custom view to the user.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 16px;&quot;&gt;
2. Doesn&#39;t catch HTTP exceptions other than 500.&lt;/h4&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter captures only the HTTP exceptions having status code 500 and by-passes the others. Let&#39;s assume we have an action that returns all the posts published for a particular category. If the category not exists then we are throwing a 404 HTTP exception.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain7&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg7&quot; preid=&quot;7&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse7&quot; preid=&quot;7&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;7&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre7&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; ViewResult Posts(&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt; category)
{
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt;(_blogRepository.Category(category) == &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;null&lt;/span&gt;)
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; HttpException(&lt;span class=&quot;code-digit&quot; style=&quot;border: 0px; color: navy; margin: 0px; padding: 0px;&quot;&gt;404&lt;/span&gt;, &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Category not found&quot;&lt;/span&gt;);

    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt; _blogRepository.Posts(category);
}&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 8. Throwing HttpException from action&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
If any user passes an invalid category a 404 exception will be thrown from the action and the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;don&#39;t catch this error. Usually in this case, programmers like to show a custom view with a message &quot;The requested category is not found or invalid&quot;. Not only the 404 exceptions, the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;doesn&#39;t catch any HTTP exception other than 500.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Handling the HTTP exceptions in filters is right or wrong is a thing for debate. In some cases we may have to bypass the HTTP exceptions to the framework to take proper action against it. So handling HTTP exceptions in filters depends upon the application and it&#39;s not mandatory!&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 16px;&quot;&gt;
3. Doesn&#39;t catch exceptions that are raised outside controllers&lt;/h4&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;is an exception filter and exception filters are called only if any exception happens inside the action or in the action filters that are applied over the action. So if the exception happens some other place the filter will be silent.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
For example, say we have set up a route constraint for a specific route as shown in the below listing.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain8&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg8&quot; preid=&quot;8&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse8&quot; preid=&quot;8&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;8&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre8&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;routes.MapRoute(
	 &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Default&quot;&lt;/span&gt;, 
	 &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Strange~Action&quot;&lt;/span&gt;,
	 &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; { controller = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;NonIE&quot;&lt;/span&gt;, action = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Action&quot;&lt;/span&gt;  },
	 &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; { browserConstraint = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; UserAgentConstraint(&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;IE&quot;&lt;/span&gt;) } 
); &lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 9. Adding constraints to routes&lt;/div&gt;
&lt;div class=&quot;para-box&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px; margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Route Constraints&lt;/code&gt;&amp;nbsp;restricts the set of URLs that a route will match against.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;UserAgentConstraint&lt;/code&gt;&amp;nbsp;that we set up in the above route restricts the route to handle requests from only Internet Explorer browsers. In the implementation of&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;UserAgentConstraint&lt;/code&gt;&amp;nbsp;I&#39;m purposely throwing an exception.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain9&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg9&quot; preid=&quot;9&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse9&quot; preid=&quot;9&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;9&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre9&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;class&lt;/span&gt; UserAgentConstraint : IRouteConstraint
{
	&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;readonly&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt; _restrictAgent;

	&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; UserAgentConstraint(&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt; restrictAgent)
	{
		_restrictAgent = restrictAgent;
	}

	&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;bool&lt;/span&gt; Match(HttpContextBase httpContext, Route route, &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt; parameterName, RouteValueDictionary values, RouteDirection routeDirection)
	{
	        &lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt; TODO: return true if the browser is not restricted one.
&lt;/span&gt;		&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; NotImplementedException(&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;You forget to implement me&quot;&lt;/span&gt;);
	}
} &lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 9. UserAgentConstraint&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
This exception is thrown at very early stage and&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter won&#39;t be there to catch this. When we access the route where the above constraint is applied we will see the yellow screen instead of the custom error page.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 16px;&quot;&gt;
4. Return error view even in exceptions occurred in AJAX calls.&lt;/h4&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
In case of AJAX calls, if some exception happens the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter returns the custom error view, which is not useful in the client-side. It would be great to return a piece of JSON in AJAX exceptions and for that we have to extend the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter or have to create a custom exception filter.&lt;/div&gt;
&lt;h3 id=&quot;handleerrorvsapperror&quot; style=&quot;background-color: white; color: #666666; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 18px; font-weight: normal;&quot;&gt;
HandleError vs. Application_Error&lt;/h3&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Exception filters are not global error handlers and this is an important reason that forces us to still rely on&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event. Some programmers don&#39;t even use the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter in their application at all and use only the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event for doing all the error handling and logging work. The important problem we face in the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event is, once the program execution reaches this point then we are out of MVC and we can&#39;t access the context objects and other useful stuff of the framework.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Another important feature that exception filters brings to us is we can handle the exceptions in different ways at different scopes, this is important in some cases, for ex. when exceptions are raised from one controller we have to return a custom error view and for other controllers we have to return a different error view, this could be easily accomplished through exception filters but not easily through the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
The bottom-line is, we need to use the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event at most of the cases in applications unless we are using a framework like ELMAH which magically handles all the exceptions. But whether we need to use the&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter or not is totally depend upon the application. When we need a controller or action level exception handling then we can use the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter along with the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event, else we can simply ignore the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter.&lt;/div&gt;
&lt;h3 id=&quot;extendinghandleerror&quot; style=&quot;background-color: white; color: #666666; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 18px; font-weight: normal;&quot;&gt;
Extending HandleError&lt;/h3&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Most of the cases we have to extend the built-in&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter or have to create a custom exception filter to do some useful job like logging. Here is an example that shows how to extend the built-in filter to log the exceptions using&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;log4net&lt;/code&gt;&amp;nbsp;and return a JSON object for AJAX calls.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain10&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg10&quot; preid=&quot;10&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse10&quot; preid=&quot;10&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;10&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre10&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;class&lt;/span&gt; CustomHandleErrorAttribute : HandleErrorAttribute
{
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;readonly&lt;/span&gt; ILog _logger;

    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; CustomHandleErrorAttribute()
    {
        _logger = LogManager.GetLogger(&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;MyLogger&quot;&lt;/span&gt;);
    }

    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;void&lt;/span&gt; OnException(ExceptionContext filterContext)
    {
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt; (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled)
        {
            &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt;;
        }

        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; HttpException(&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;null&lt;/span&gt;, filterContext.Exception).GetHttpCode() != &lt;span class=&quot;code-digit&quot; style=&quot;border: 0px; color: navy; margin: 0px; padding: 0px;&quot;&gt;500&lt;/span&gt;)
        {
            &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt;;
        }

        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt; (!ExceptionType.IsInstanceOfType(filterContext.Exception))
        {
            &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt;;
        }

        &lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt; if the request is AJAX return JSON else view.
&lt;/span&gt;        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt; (filterContext.HttpContext.Request.Headers[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;X-Requested-With&quot;&lt;/span&gt;] == &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;XMLHttpRequest&quot;&lt;/span&gt;)
        {
            filterContext.Result = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; JsonResult 
            { 
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, 
                Data = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; 
                { 
                    error = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;true&lt;/span&gt;,
                    message = filterContext.Exception.Message
                } 
            };
        }
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;else&lt;/span&gt;
        {
            &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; controllerName = (&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt;)filterContext.RouteData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;controller&quot;&lt;/span&gt;];
            &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; actionName = (&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;string&lt;/span&gt;)filterContext.RouteData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;action&quot;&lt;/span&gt;];
            &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; model = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; HandleErrorInfo(filterContext.Exception, controllerName, actionName);
            
            filterContext.Result = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; ViewResult
            {
                ViewName = View,
                MasterName = Master,
                ViewData = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; ViewDataDictionary&amp;lt;HandleErrorInfo&amp;gt;(model),
                TempData = filterContext.Controller.TempData
            };
        }

        &lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt; log the error using log4net.
&lt;/span&gt;        _logger.Error(filterContext.Exception.Message, filterContext.Exception);

        filterContext.ExceptionHandled = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;true&lt;/span&gt;;
        filterContext.HttpContext.Response.Clear();
        filterContext.HttpContext.Response.StatusCode = &lt;span class=&quot;code-digit&quot; style=&quot;border: 0px; color: navy; margin: 0px; padding: 0px;&quot;&gt;500&lt;/span&gt;;

        filterContext.HttpContext.Response.TrySkipIisCustomErrors = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;true&lt;/span&gt;;      
    }
}&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 10. Extending HandleError&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Most of the code are same as in the built-in filter. Notice we have ignored the HTTP exceptions so anyway we need to wire-up the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event to catch and log the missed exceptions. If the request is an AJAX call then we are returning a JSON object that contains a boolean and the exception message else we are returning the error view. We are setting the response status code as 500 and the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter also does the same, this is important in terms of REST and HTTP standards.&lt;/div&gt;
&lt;h3 id=&quot;returningviews&quot; style=&quot;background-color: white; color: #666666; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 18px; font-weight: normal;&quot;&gt;
Returning views from Application_Error&lt;/h3&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
In some applications we have to depend upon the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event for handling all the exceptions or the ones that are missed by the exception filters. Mostly programmers like to return an MVC view instead of a static page. Though we are out of the MVC context still we can return a view using a controller (thanks to StackOverflow).&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Let&#39;s create an&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Error&lt;/code&gt;&amp;nbsp;controller that return different views for different errors as shown in the below listing.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain11&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg11&quot; preid=&quot;11&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse11&quot; preid=&quot;11&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;11&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre11&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;class&lt;/span&gt; ErrorController : Controller
{
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; ActionResult Index()
    {
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt; View();
    }

    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; ActionResult NotFound()
    {
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;return&lt;/span&gt; View();
    }
}&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 11. Error Controller&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
We have to invoke this&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Error&lt;/code&gt;&amp;nbsp;controller from the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;to return a view after the exception is logged.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain12&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg12&quot; preid=&quot;12&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse12&quot; preid=&quot;12&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;12&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre12&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;void&lt;/span&gt; Application_Error(&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
{
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; httpContext = ((MvcApplication)sender).Context;
    
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; currentRouteData = RouteTable.Routes.GetRouteData(&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; HttpContextWrapper(httpContext));    
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; currentController = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt; &quot;&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; currentAction = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt; &quot;&lt;/span&gt;;
    
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt;(currentRouteData != &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;null&lt;/span&gt;)
    {
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt;(currentRouteData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;controller&quot;&lt;/span&gt;] != &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !String.IsNullOrEmpty(currentRouteData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;controller&quot;&lt;/span&gt;].ToString()))
        {
            currentController = currentRouteData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;controller&quot;&lt;/span&gt;].ToString();
        }
        
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt;(currentRouteData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;action&quot;&lt;/span&gt;] != &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !String.IsNullOrEmpty(currentRouteData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;action&quot;&lt;/span&gt;].ToString()))
        {
            currentAction = currentRouteData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;action&quot;&lt;/span&gt;].ToString();
        }
    }
    
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; ex = Server.GetLastError();

    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; controller = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; ErrorController();
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; routeData = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; RouteData();
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; action = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Index&quot;&lt;/span&gt;;

    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt; (ex &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;is&lt;/span&gt; HttpException)
    {
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;var&lt;/span&gt; httpEx = ex &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;as&lt;/span&gt; HttpException;

        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;switch&lt;/span&gt; (httpEx.GetHttpCode())
        {
            &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;code-digit&quot; style=&quot;border: 0px; color: navy; margin: 0px; padding: 0px;&quot;&gt;404&lt;/span&gt;:
                action = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;NotFound&quot;&lt;/span&gt;;
                &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;break&lt;/span&gt;;

            &lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt; others if any
&lt;/span&gt;
            &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;default&lt;/span&gt;:
                action = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Index&quot;&lt;/span&gt;;
                &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;break&lt;/span&gt;;
        }
    }

    httpContext.ClearError();
    httpContext.Response.Clear();
    httpContext.Response.StatusCode = ex &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;is&lt;/span&gt; HttpException ? ((HttpException)ex).GetHttpCode() : &lt;span class=&quot;code-digit&quot; style=&quot;border: 0px; color: navy; margin: 0px; padding: 0px;&quot;&gt;500&lt;/span&gt;;
    httpContext.Response.TrySkipIisCustomErrors = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;true&lt;/span&gt;;
    routeData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;controller&quot;&lt;/span&gt;] = &lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;Error&quot;&lt;/span&gt;;
    routeData.Values[&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px;&quot;&gt;action&quot;&lt;/span&gt;] = action;

    controller.ViewData.Model = &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; HandleErrorInfo(ex, currentController, currentAction);    
    ((IController)controller).Execute(&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; RequestContext(&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;new&lt;/span&gt; HttpContextWrapper(httpContext), routeData));
} &lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 12. Returning views from Application_Error&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
We are doing many things in the above code, mainly we are instantiating the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Error&lt;/code&gt;&amp;nbsp;controller and invoking it by calling the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Execute()&lt;/code&gt;&amp;nbsp;method passing the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleErrorInfo&lt;/code&gt;&amp;nbsp;model and this is the model used by the&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter as well.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
We are using a switch statement just to demonstrate how we can return different error views for different HTTP exceptions. If you want to take care of AJAX calls you have to change the implementation little as we did in the custom&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter but to keep things simple I&#39;ve ignored that part.&lt;/div&gt;
&lt;h3 id=&quot;elmah&quot; style=&quot;background-color: white; color: #666666; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 18px; font-weight: normal;&quot;&gt;
ELMAH&lt;/h3&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. You can easily configure ELMAH for an ASP.NET MVC application without much code. The other benefits brought up by ELMAH is, it provides a custom page where the admin can view the errors including the original yellow screen, also it provides options to send emails, generate RSS etc.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
ELMAH logs only unhandled exceptions so we have to signal ELMAH to log the exceptions that are handled. When we use the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter and ELMAH in an application we will confused seeing no exceptions are logged by ELMAH, it&#39;s because once the exceptions are handled by the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter it sets the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;ExceptionHandled&lt;/code&gt;property of the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;ExceptionContext&lt;/code&gt;&amp;nbsp;object to true and that hides the errors from logged by ELMAH. A better way to overcome this problem is extend the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter and signal to ELMAH as shown in the below listing.&lt;/div&gt;
&lt;div class=&quot;pre-action-link&quot; id=&quot;premain13&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;&quot; width=&quot;100%&quot;&gt;
&lt;img height=&quot;9&quot; id=&quot;preimg13&quot; preid=&quot;13&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;border: 0px; cursor: pointer; height: auto; margin: 0px; max-width: 100%; overflow: auto; padding: 0px;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse13&quot; preid=&quot;13&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;span style=&quot;border: 0px; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/422572/Exception-Handling-in-ASP-NET-MVC#&quot; preid=&quot;13&quot; style=&quot;border: 0px; color: purple; margin: 0px; padding: 0px; text-decoration: initial;&quot;&gt;Copy Code&lt;/a&gt;&lt;/div&gt;
&lt;pre id=&quot;pre13&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;class&lt;/span&gt; ElmahHandleErrorAttribute : HandleErrorAttribute
{
    &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;void&lt;/span&gt; OnException(ExceptionContext filterContext)
    {
        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;base&lt;/span&gt;.OnException(filterContext);

        &lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;&quot;&gt; signal ELMAH to log the exception
&lt;/span&gt;        &lt;span class=&quot;code-keyword&quot; style=&quot;border: 0px; color: blue; margin: 0px; padding: 0px;&quot;&gt;if&lt;/span&gt; (filterContext.ExceptionHandled)
            ErrorSignal.FromCurrentContext().Raise(filterContext.Exception);
    }
}&lt;/pre&gt;
&lt;div class=&quot;Caption&quot; style=&quot;background-color: white; border: 0px; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 12px; font-style: italic; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;
Listing 13. Signaling to Elmah&lt;/div&gt;
&lt;h3 id=&quot;summary&quot; style=&quot;background-color: white; color: #666666; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 18px; font-weight: normal;&quot;&gt;
Summary&lt;/h3&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
In this article we saw about the built-in&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter available with ASP.NET MVC to handle the exceptions. The&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter has some limitations and most importantly it doesn&#39;t handle all the exceptions that are raised by the application.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
Although&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;&amp;nbsp;filter bring some benefits in customizing error handling at a controller or action level still we have to rely on the&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;Application_Error&lt;/code&gt;&amp;nbsp;event.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #111111; font-family: &#39;Segoe UI&#39;, Arial, sans-serif; font-size: 14px;&quot;&gt;
ELMAH is an error handling module that is easily pluggable to an ASP.NET application. Unlike&amp;nbsp;&lt;code style=&quot;border: 0px; color: #990000; font-family: Consolas, &#39;Courier New&#39;, Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;&quot;&gt;HandleError&lt;/code&gt;, ELMAH catches all the exceptions raised by the application.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/8273062885998926320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/exception-handling-in-aspnet-mvc_7998.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/8273062885998926320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/8273062885998926320'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/exception-handling-in-aspnet-mvc_7998.html' title='Exception Handling in ASP.NET MVC'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-3734268022401837822</id><published>2012-12-07T18:33:00.000+05:30</published><updated>2012-12-07T18:33:33.486+05:30</updated><title type='text'>Appication Life Cycle of Asp.Net</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5enA1BJ9AxyopvuB34uQUws0lwpwvYN7vr_tln-TcnK2YdUi4IX1pQRX0hnIBWB47h3xhThEs6LGaV0UE_iXFjd4YfpuI8JUNW1GC47xQLocjizmMdmvUDEEvUdSYYxXaruy2N7ZdHRSu/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5enA1BJ9AxyopvuB34uQUws0lwpwvYN7vr_tln-TcnK2YdUi4IX1pQRX0hnIBWB47h3xhThEs6LGaV0UE_iXFjd4YfpuI8JUNW1GC47xQLocjizmMdmvUDEEvUdSYYxXaruy2N7ZdHRSu/s400/2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/3734268022401837822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/appication-life-cycle-of-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/3734268022401837822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/3734268022401837822'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/appication-life-cycle-of-aspnet.html' title='Appication Life Cycle of Asp.Net'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5enA1BJ9AxyopvuB34uQUws0lwpwvYN7vr_tln-TcnK2YdUi4IX1pQRX0hnIBWB47h3xhThEs6LGaV0UE_iXFjd4YfpuI8JUNW1GC47xQLocjizmMdmvUDEEvUdSYYxXaruy2N7ZdHRSu/s72-c/2.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-7993501923710776256</id><published>2012-12-07T18:30:00.002+05:30</published><updated>2012-12-07T18:31:49.940+05:30</updated><title type='text'>All Joins in Sql Server</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx91PulCzUwJFAgHzHZnQK7_lb5vyeAq70F3vapYDq-nP6pu4U8HmnoWpgLNnUxLnyycOf2Pqy-BuE3lGxfOzQBXbzKbuIMs4nQCwPbrZxyyPLDgmspK6P98mYBT5QlcHlzCYdtcjbqlI0/s1600/Visual_SQL_JOINS_V2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx91PulCzUwJFAgHzHZnQK7_lb5vyeAq70F3vapYDq-nP6pu4U8HmnoWpgLNnUxLnyycOf2Pqy-BuE3lGxfOzQBXbzKbuIMs4nQCwPbrZxyyPLDgmspK6P98mYBT5QlcHlzCYdtcjbqlI0/s1600/Visual_SQL_JOINS_V2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/7993501923710776256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/all-joins-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7993501923710776256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7993501923710776256'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/12/all-joins-in-sql-server.html' title='All Joins in Sql Server'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx91PulCzUwJFAgHzHZnQK7_lb5vyeAq70F3vapYDq-nP6pu4U8HmnoWpgLNnUxLnyycOf2Pqy-BuE3lGxfOzQBXbzKbuIMs4nQCwPbrZxyyPLDgmspK6P98mYBT5QlcHlzCYdtcjbqlI0/s72-c/Visual_SQL_JOINS_V2.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-7830663065931384103</id><published>2012-11-27T15:33:00.001+05:30</published><updated>2012-11-27T15:33:21.320+05:30</updated><title type='text'>FileUpload control working on second click but not at first click?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Change &amp;nbsp;your master page form tag as like this&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;lang-cs prettyprint prettyprinted&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;form id&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;form1&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; enctype&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;multipart/form-data&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; runat&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/7830663065931384103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/11/fileupload-control-working-on-second.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7830663065931384103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7830663065931384103'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/11/fileupload-control-working-on-second.html' title='FileUpload control working on second click but not at first click?'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-5078423081489854068</id><published>2012-11-27T15:31:00.000+05:30</published><updated>2012-11-27T15:31:04.592+05:30</updated><title type='text'>FileUpload control not Working in UpdatePanel asp.net</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Add this code in UpdatePanel&lt;br /&gt;
&amp;nbsp;&amp;lt;Triggers&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;asp:PostBackTrigger ControlID=&quot;btnSubmit&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/Triggers&amp;gt;&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/5078423081489854068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/11/fileupload-control-not-working-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5078423081489854068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5078423081489854068'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/11/fileupload-control-not-working-in.html' title='FileUpload control not Working in UpdatePanel asp.net'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-8966425802597655726</id><published>2012-11-06T17:38:00.001+05:30</published><updated>2012-11-06T17:38:50.405+05:30</updated><title type='text'>Difference between HTTP handlers and HTTP modules</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; font-family: Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 8px; margin-top: 8px; padding: 0px;&quot;&gt;
HTTP handlers are the end point objects in&amp;nbsp;ASP.NET pipeline and an HTTP Handler essentially processes the request and produces the response. For example an ASP.NET Page&amp;nbsp;is an HTTP Handler.&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 8px; margin-top: 8px; padding: 0px;&quot;&gt;
HTTP Modules are objects which also participate the&amp;nbsp;pipeline but they work before and after the HTTP Handler does its&amp;nbsp;job and produce additional services within the pipeline (for example associating session within a request before HTTP handler executes, and saving the session&amp;nbsp;state after HTTP handler has done its job, is basically done by an HTTP module, SessionStateModule)&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/8966425802597655726/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/11/difference-between-http-handlers-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/8966425802597655726'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/8966425802597655726'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/11/difference-between-http-handlers-and.html' title='Difference between HTTP handlers and HTTP modules'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-5666680303506228516</id><published>2012-11-06T16:39:00.000+05:30</published><updated>2012-11-06T16:39:05.268+05:30</updated><title type='text'>Dynamically changing master in ASP.NET , C#</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&amp;nbsp;protected void Page_PreInit(object seder, EventArgs e)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.MasterPageFile = &quot;~/MasterPage.master&quot;;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/5666680303506228516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/11/dynamically-changing-master-in-aspnet-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5666680303506228516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5666680303506228516'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/11/dynamically-changing-master-in-aspnet-c.html' title='Dynamically changing master in ASP.NET , C#'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-4134486506602989824</id><published>2012-08-24T14:53:00.002+05:30</published><updated>2012-08-25T12:06:01.357+05:30</updated><title type='text'>Ajax ComboBox Validation in JavaScript </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
var cmb = document.getElementById(&#39;&amp;lt;%=cmbwno.ClientID %&amp;gt;&#39;);&lt;br /&gt;
&amp;nbsp;var string = cmb.control._originalSelectedIndex;&lt;br /&gt;
&amp;nbsp; if (string == 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;alert(&quot;Select Worker Number&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; document.getElementById(&#39;&amp;lt;%=cmbwno.ClientID %&amp;gt;&#39;).focus();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
but Here combobox must be auto postback &amp;nbsp;true&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/4134486506602989824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/ajax-combobox-validation-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/4134486506602989824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/4134486506602989824'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/ajax-combobox-validation-in-javascript.html' title='Ajax ComboBox Validation in JavaScript '/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-919071916767781602</id><published>2012-08-22T23:02:00.002+05:30</published><updated>2012-08-22T23:02:21.462+05:30</updated><title type='text'>Simple Email validation in Javascript</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
function is_email(email) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return emailReg.test(email);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/919071916767781602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/simple-email-validation-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/919071916767781602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/919071916767781602'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/simple-email-validation-in-javascript.html' title='Simple Email validation in Javascript'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-6941361784520722516</id><published>2012-08-22T12:35:00.003+05:30</published><updated>2012-08-22T12:35:25.984+05:30</updated><title type='text'>Display Row Number or SNO for Gridview Asp.Net</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&amp;nbsp;&amp;lt;asp:TemplateField HeaderText=&quot;S.NO.&quot;&amp;gt; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;lt;ItemTemplate&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;lt;asp:Label ID=&quot;Label1&quot; runat=&quot;server&quot; Text=&#39;&amp;lt;%# Container.DataItemIndex + 1 %&amp;gt; &#39;&amp;gt;&lt;br /&gt;
&amp;lt;/asp:Label&amp;gt;&amp;nbsp;&lt;br /&gt;
&amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/6941361784520722516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/display-row-number-or-sno-for-gridview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/6941361784520722516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/6941361784520722516'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/display-row-number-or-sno-for-gridview.html' title='Display Row Number or SNO for Gridview Asp.Net'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-647931529784104043</id><published>2012-08-21T22:54:00.000+05:30</published><updated>2012-08-21T22:54:03.956+05:30</updated><title type='text'>Get selected text of dropdownlist  in Javascript</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
ddlTime.options[ddlTime.selectedIndex].innerHTML&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/647931529784104043/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/get-selected-text-of-dropdownlist-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/647931529784104043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/647931529784104043'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/get-selected-text-of-dropdownlist-in.html' title='Get selected text of dropdownlist  in Javascript'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-441734694842689851</id><published>2012-08-19T20:37:00.001+05:30</published><updated>2012-08-19T20:37:47.460+05:30</updated><title type='text'>Send mail from gmail C# Asp.Net</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&amp;nbsp; MailMessage mail = new MailMessage();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;mail.To.Add(txtUM.Text);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;mail.From = new MailAddress(&quot;pavan.it30@gmail.com&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;mail.Subject = &quot;Welcome To NL SOFTTECH SERVICES!!&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string Body = &quot;User ID :&quot;+txtUI.Text+&quot; Password :&quot;+txtPass.Text;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; mail.Body = Body;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; mail.IsBodyHtml = true;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //mail.Attachments.Add(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SmtpClient smtp = new SmtpClient();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;smtp.Host = ConfigurationManager.AppSettings[&quot;SMTP&quot;];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings[&quot;FROMEMAIL&quot;], ConfigurationManager.AppSettings[&quot;FROMPWD&quot;]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; smtp.EnableSsl = true; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;smtp.Send(mail);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Label1.Text = &quot;Mail Sent Successfully&quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;and add this tag in web.config&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;appSettings&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;!--&amp;lt;add key=&quot;SMTP&quot; value=&quot;smtp.gmail.com&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;add key=&quot;FROMEMAIL&quot; value=&quot;pavan.it30@gmail.com&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;add key=&quot;FROMPWD&quot; value=&quot;&quot;/&amp;gt;--&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/441734694842689851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/send-mail-from-gmail-c-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/441734694842689851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/441734694842689851'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/send-mail-from-gmail-c-aspnet.html' title='Send mail from gmail C# Asp.Net'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-7295189624570888793</id><published>2012-08-19T20:34:00.002+05:30</published><updated>2012-08-19T20:34:46.136+05:30</updated><title type='text'>Send mail  Code C#  Asp.Net</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
SmtpClient smtpClient = new SmtpClient();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MailAddress fromAddress = new MailAddress(&quot;charan@citycinemas.in&quot;, &quot;CityCinemas&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; smtpClient.Host = &quot;202.0.103.18&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; smtpClient.Port = 25;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; message.From = fromAddress;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; message.To.Add(&quot;pavan.it30@gmail.com&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; message.Subject = &quot;Ticket Details&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //message.CC.Add(&quot;anil.vnkta@gmail.com&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // message.CC.Add(&quot;&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // You can specify Address directly as string&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // message.Bcc.Add(new MailAddress(&quot;&quot;));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //message.Bcc.Add(new MailAddress(&quot;&quot;));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; message.IsBodyHtml = true;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; message.Body = MailBody;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; smtpClient.Send(message);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception ex)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/7295189624570888793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/send-mail-code-c-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7295189624570888793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7295189624570888793'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/send-mail-code-c-aspnet.html' title='Send mail  Code C#  Asp.Net'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-8356001893262921978</id><published>2012-08-18T23:01:00.000+05:30</published><updated>2012-08-18T23:01:04.516+05:30</updated><title type='text'>Read GriedView from javascript (Template feild like TextBox,Image,Buttom..etc)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&amp;nbsp; function ListOutSelectedSeats() {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var selectedSeats = document.getElementById(&#39;&amp;lt;%=hf.ClientID%&amp;gt;&#39;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; selectedSeats.value = &quot;&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var grid = document.getElementById(&#39;&amp;lt;%=gvScreenLayout.ClientID %&amp;gt;&#39;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (i = 0; i &amp;lt; grid.rows.length; i++) {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (j = 0; j &amp;lt; grid.rows[i].cells.length; j++) {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; col1 = grid.rows[i].cells[j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //col2 = grid.rows[i].cells[1];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var Level = grid.rows[i].cells[0].innerHTML;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var RowName = grid.rows[i].cells[1].innerHTML;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (k = 0; k &amp;lt; col1.childNodes.length; k++) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (col1.childNodes[k].type == &quot;image&quot;) {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (col1.childNodes[k].src.toString().indexOf(&quot;images/design_seats/small_Avail.jpg&quot;) &amp;gt;= 0) {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var imgid = col1.childNodes[k].id.toString();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var ind = imgid.indexOf(&quot;ImageButton&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var Number = imgid.substr(ind + 11, 2);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (isNumeric(Number) == true) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Number = imgid.substr(ind + 11, 2);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; selectedSeats.value = selectedSeats.value + &quot;,&quot; + Level + &quot;_&quot; + RowName + &quot;_&quot; + Number;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Number = imgid.substr(ind + 11, 1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; selectedSeats.value = selectedSeats.value + &quot;,&quot; + Level + &quot;_&quot; + RowName + &quot;_&quot; + Number;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/8356001893262921978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/read-griedview-from-javascript-template.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/8356001893262921978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/8356001893262921978'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/read-griedview-from-javascript-template.html' title='Read GriedView from javascript (Template feild like TextBox,Image,Buttom..etc)'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-9062068725893148204</id><published>2012-08-18T22:56:00.001+05:30</published><updated>2012-08-18T22:56:08.744+05:30</updated><title type='text'>Delete all directory cookies in javascript</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var name = &quot;loginstatus&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var pathBits = location.pathname.split(&#39;/&#39;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var pathCurrent = &#39; path=&#39;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // do a simple pathless delete first.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; document.cookie = name + &#39;=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/; domain = www.citycinemas.in;&#39;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (var i = 0; i &amp;lt; pathBits.length; i++) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pathCurrent += ((pathCurrent.substr(-1) != &#39;/&#39;) ? &#39;/&#39; : &#39;&#39;) + pathBits[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; document.cookie = name + &#39;=; expires=Thu, 01-Jan-70 00:00:01 GMT;&#39; + pathCurrent + &#39;;&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/9062068725893148204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/delete-all-directory-cookies-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/9062068725893148204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/9062068725893148204'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/delete-all-directory-cookies-in.html' title='Delete all directory cookies in javascript'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-5190231560114511477</id><published>2012-08-18T22:52:00.002+05:30</published><updated>2012-08-18T22:52:28.027+05:30</updated><title type='text'>Cookie for all directories in javascript</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&amp;nbsp;var loginst = &quot;loginstatus&quot;;&lt;br /&gt;
var&amp;nbsp;value=&quot;vvv&quot;;&lt;br /&gt;
&amp;nbsp;document.cookie = loginst + &quot;=&quot; + value+&quot;;path=/;&quot;;&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/5190231560114511477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/cookie-for-all-directories-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5190231560114511477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5190231560114511477'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/cookie-for-all-directories-in-javascript.html' title='Cookie for all directories in javascript'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-4941155303569662377</id><published>2012-08-18T22:25:00.000+05:30</published><updated>2012-08-18T22:25:12.802+05:30</updated><title type='text'>Load a page to Parent Page IFRAME in javascript</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp;parent.window.frames[&#39;fr1&#39;].location = &#39;PrintTicket.aspx&#39;;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/4941155303569662377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/load-page-to-parent-page-iframe-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/4941155303569662377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/4941155303569662377'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/load-page-to-parent-page-iframe-in.html' title='Load a page to Parent Page IFRAME in javascript'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-5676481050494692804</id><published>2012-08-18T22:23:00.002+05:30</published><updated>2012-08-18T22:23:43.015+05:30</updated><title type='text'>dynamically load  a page  to IFRAME  in javascript</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp;$(&quot;#frameDiv&quot;).html(&quot;&amp;lt;iframe src=&#39;user/BookByMovie.aspx&#39; id=&#39;fr1&#39; width=&#39;100%&#39; name=&#39;fr1&#39; /&amp;gt;&amp;lt;/iframe&amp;gt;&quot;);&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/5676481050494692804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/dynamically-load-page-to-iframe-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5676481050494692804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/5676481050494692804'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/dynamically-load-page-to-iframe-in.html' title='dynamically load  a page  to IFRAME  in javascript'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-7529355084479313708</id><published>2012-08-18T22:19:00.005+05:30</published><updated>2012-08-18T22:19:54.265+05:30</updated><title type='text'>Set Auto height to iframe in javascript</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre class=&quot;bbcode_code&quot; style=&quot;background-color: #f4f4f4; background-repeat: repeat no-repeat; border: 1px inset; color: #464646; direction: ltr; font-size: 12px; height: 44em; line-height: 12px; overflow: auto; padding: 6px;&quot;&gt;script type=&#39;text/javascript&#39;&amp;gt;

function setIframeHeight( iframeId ) /** IMPORTANT: All framed documents *must* have a DOCTYPE applied **/
{
 var ifDoc, ifRef = document.getElementById( iframeId );

 try
 {   
  ifDoc = ifRef.contentWindow.document.documentElement;  
 }
 catch( e )
 { 
  try
  { 
   ifDoc = ifRef.contentDocument.documentElement;  
  }
  catch(ee)
  {   
  }  
 }
 
 if( ifDoc )
 {
  ifRef.height = 1;  
  ifRef.height = ifDoc.scrollHeight;
  
  /* For width resize, enable below.  */
  
  // ifRef.width = 1;
  // ifRef.width = ifDoc.scrollWidth; 
 }
}

&amp;lt;/script&amp;gt;

&amp;lt;iframe id = &quot;myIframe&quot;  onload = &quot;setIframeHeight( this.id )&quot;&amp;gt;&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/7529355084479313708/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/set-auto-height-to-iframe-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7529355084479313708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7529355084479313708'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/set-auto-height-to-iframe-in-javascript.html' title='Set Auto height to iframe in javascript'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-2496470350894493457</id><published>2012-08-17T16:43:00.000+05:30</published><updated>2012-08-17T18:26:47.418+05:30</updated><title type='text'>double or float convert to currency format C# </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;pre class=&quot;lang-cs prettyprint&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;double amount=1234;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-cs prettyprint&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;amount.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;ToString&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;#,##0.00&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-cs prettyprint&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Then resulting string is 1,234.00&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-cs prettyprint&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/2496470350894493457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/double-or-float-convert-to-currency.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/2496470350894493457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/2496470350894493457'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/double-or-float-convert-to-currency.html' title='double or float convert to currency format C# '/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-7535506151880122071</id><published>2012-08-17T15:28:00.003+05:30</published><updated>2012-08-19T20:32:17.545+05:30</updated><title type='text'> Call a URL and save the response C# ASP.NET</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
string url = &quot;http://69.50.198.112/send.php?usr=24129&amp;amp;pwd=123456&amp;amp;ph=9030102460&amp;amp;text=fromApp&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;WebRequest request = HttpWebRequest.Create(url);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WebResponse response = request.GetResponse();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; StreamReader reader = new StreamReader(response.GetResponseStream());&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string urlText = reader.ReadToEnd();&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/7535506151880122071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/call-url-and-save-response.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7535506151880122071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/7535506151880122071'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/call-url-and-save-response.html' title=' Call a URL and save the response C# ASP.NET'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5353130915959995656.post-2442406749410486233</id><published>2012-08-13T20:40:00.003+05:30</published><updated>2012-10-12T20:49:38.423+05:30</updated><title type='text'>Run application Shortcut from Command Prompt or batch file</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;Start Call &amp;nbsp;&lt;/b&gt;&lt;b&gt;&quot;C:\Program Files (x86)\TECHNOARCHIVE\MailCityCinemas\CityCinemas.exe&quot;&amp;nbsp;&lt;/b&gt;&amp;nbsp;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;OR&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;start &quot;&quot; &quot;C:\Program Files (x86)\TECHNOARCHIVE\MailCityCinemas\CityCinemas.exe&quot;&amp;nbsp;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetwithcsharperrors.blogspot.com/feeds/2442406749410486233/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/run-application-shortcut-from-command.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/2442406749410486233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5353130915959995656/posts/default/2442406749410486233'/><link rel='alternate' type='text/html' href='http://aspdotnetwithcsharperrors.blogspot.com/2012/08/run-application-shortcut-from-command.html' title='Run application Shortcut from Command Prompt or batch file'/><author><name>PAVAN KUMAR</name><uri>http://www.blogger.com/profile/13597330029418429297</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLbe-S78zGg7ZL5SwhiRqZIhADs6pNksWyoIH-r_UWzWslVZEibWBItFSDrMyPebN8YlqrkcCfN0MyBKGc5SoOUnl0Nrbo6XnNOGhf_PAUSNrh4C0WJDRB2TiQflzGJM/s220/p.jpg'/></author><thr:total>0</thr:total></entry></feed>