<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Use jQuery to catch and display ASP.NET AJAX service errors</title>
	<atom:link href="http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/feed/" rel="self" type="application/rss+xml" />
	<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/</link>
	<description>ASP.NET and AJAX code, ideas, and examples.</description>
	<lastBuildDate>Thu, 11 Mar 2010 18:05:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-38230</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Fri, 05 Mar 2010 18:35:18 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-38230</guid>
		<description>You can definitely do something like this with MVC, but the implementation won&#039;t be very similar at all.  I wouldn&#039;t suggest using this post as a starting point for MVC AJAX error handling.</description>
		<content:encoded><![CDATA[<p>You can definitely do something like this with MVC, but the implementation won&#8217;t be very similar at all.  I wouldn&#8217;t suggest using this post as a starting point for MVC AJAX error handling.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-38179</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Tue, 02 Mar 2010 05:23:10 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-38179</guid>
		<description>How can this be applied to c# and MVC?  

I have a controller, not a webmethod so when my controller method throws an exception, the resulting error returned to the browser contains the well formatted HTML error message .Net generates, rather than just the error message the thrown exception returns....</description>
		<content:encoded><![CDATA[<p>How can this be applied to c# and MVC?  </p>
<p>I have a controller, not a webmethod so when my controller method throws an exception, the resulting error returned to the browser contains the well formatted HTML error message .Net generates, rather than just the error message the thrown exception returns&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Use jQuery to catch and display MR AJAX errors &#171; Chorn Sokun&#8217;s Weblog</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-36592</link>
		<dc:creator>Use jQuery to catch and display MR AJAX errors &#171; Chorn Sokun&#8217;s Weblog</dc:creator>
		<pubDate>Thu, 01 Oct 2009 17:59:01 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-36592</guid>
		<description>[...] a comment &#187;  This post influenced Dave Ward&#8217;s post to replicate the behavior that he discussed within MonoRail application.  To mimic this behavior [...]</description>
		<content:encoded><![CDATA[<p>[...] a comment &raquo;  This post influenced Dave Ward&#8217;s post to replicate the behavior that he discussed within MonoRail application.  To mimic this behavior [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miroslav Ninkovic</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-36496</link>
		<dc:creator>Miroslav Ninkovic</dc:creator>
		<pubDate>Fri, 18 Sep 2009 07:30:13 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-36496</guid>
		<description>Thanks Dave!</description>
		<content:encoded><![CDATA[<p>Thanks Dave!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-36493</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Thu, 17 Sep 2009 21:30:53 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-36493</guid>
		<description>MVC doesn&#039;t return its errors in the same format as ASP.NET AJAX services.  That&#039;s normal behavior.</description>
		<content:encoded><![CDATA[<p>MVC doesn&#8217;t return its errors in the same format as ASP.NET AJAX services.  That&#8217;s normal behavior.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adauto</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-36489</link>
		<dc:creator>Adauto</dc:creator>
		<pubDate>Thu, 17 Sep 2009 17:26:26 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-36489</guid>
		<description>You may be receiving HTML string because the error didn&#039;t came from a thrown exception. I noticed that when it is a Internal Server Error (500) it shows the error page defined.</description>
		<content:encoded><![CDATA[<p>You may be receiving HTML string because the error didn&#8217;t came from a thrown exception. I noticed that when it is a Internal Server Error (500) it shows the error page defined.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miroslav Ninkovic</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-36488</link>
		<dc:creator>Miroslav Ninkovic</dc:creator>
		<pubDate>Thu, 17 Sep 2009 14:46:23 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-36488</guid>
		<description>Indeed, a great post. I&#039;m using it to make ASP.NET MVC ajax calls. But there is a &#039;little&#039; issue. The response text in xhr.responseText is HTML string, not JSON string.
To be honest, this sounds normal for me and when server returns JSON string is strange for me :). Apparently is that, since I&#039;m the only one with this problem, I&#039;m missing something. Do you know what?
Thanks!</description>
		<content:encoded><![CDATA[<p>Indeed, a great post. I&#8217;m using it to make ASP.NET MVC ajax calls. But there is a &#8216;little&#8217; issue. The response text in xhr.responseText is HTML string, not JSON string.<br />
To be honest, this sounds normal for me and when server returns JSON string is strange for me :). Apparently is that, since I&#8217;m the only one with this problem, I&#8217;m missing something. Do you know what?<br />
Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jrummell</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-35634</link>
		<dc:creator>jrummell</dc:creator>
		<pubDate>Tue, 23 Jun 2009 12:17:01 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-35634</guid>
		<description>Yes, you are correct. Changing customErrors to 
&lt;pre lang=&quot;xml&quot;&gt;
&lt;customErrors mode=&quot;Off&quot; /&gt;
&lt;/pre&gt; 
fixed it. Thanks!</description>
		<content:encoded><![CDATA[<p>Yes, you are correct. Changing customErrors to</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #ddbb00;">&amp;lt;</span>customErrors mode=&quot;Off&quot; /<span style="color: #ddbb00;">&amp;gt;</span></pre></div></div>

<p>fixed it. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-35628</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Mon, 22 Jun 2009 20:11:26 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-35628</guid>
		<description>I believe the customErrors setting in your web.config controls that.</description>
		<content:encoded><![CDATA[<p>I believe the customErrors setting in your web.config controls that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jrummell</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-35620</link>
		<dc:creator>jrummell</dc:creator>
		<pubDate>Mon, 22 Jun 2009 18:08:29 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-35620</guid>
		<description>Hi Dave. Thank you for this awesome post! 

I&#039;m running into a problem where I can&#039;t get the exception details when I test a web service from a machine that is not the web server. (machine A has the html page open in a browser that calls a WebService on machine b)

This is what I get:

&lt;pre lang=&quot;javascript&quot;&gt;
{&quot;Message&quot;:&quot;There was an error processing the request.&quot;,&quot;StackTrace&quot;:&quot;&quot;,&quot;ExceptionType&quot;:&quot;&quot;}
&lt;/pre&gt;

I tried changing debug to true in web.config, but that didn&#039;t make a difference. Any ideas?</description>
		<content:encoded><![CDATA[<p>Hi Dave. Thank you for this awesome post! </p>
<p>I&#8217;m running into a problem where I can&#8217;t get the exception details when I test a web service from a machine that is not the web server. (machine A has the html page open in a browser that calls a WebService on machine b)</p>
<p>This is what I get:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;Message&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;There was an error processing the request.&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;StackTrace&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;ExceptionType&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>I tried changing debug to true in web.config, but that didn&#8217;t make a difference. Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adauto</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-35598</link>
		<dc:creator>Adauto</dc:creator>
		<pubDate>Thu, 18 Jun 2009 16:45:39 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-35598</guid>
		<description>I had the same problem. When the exception comes from an Interval Server Error (500), the StackTrace page is shown. I ended up with two solutions. I could either change the Application_Error or get the error through javascript somewhere in the error page. So i decided to go for the second one. By doing this i don’t mess up with the Global.asax.

&lt;pre lang=&quot;x&quot;&gt;
error: function(result, textStatus, thrownError){
result.responseText.match(/(.*)/i);
MostraCaixa(”AVISO DE ERRO”, error[1] &#124;&#124; result.responseText, Botoes.OkAlerta);
$(”.close:visible”).focus();
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I had the same problem. When the exception comes from an Interval Server Error (500), the StackTrace page is shown. I ended up with two solutions. I could either change the Application_Error or get the error through javascript somewhere in the error page. So i decided to go for the second one. By doing this i don’t mess up with the Global.asax.</p>

<div class="wp_syntax"><div class="code"><pre class="x" style="font-family:monospace;">error: function(result, textStatus, thrownError){
result.responseText.match(/(.*)/i);
MostraCaixa(”AVISO DE ERRO”, error[1] || result.responseText, Botoes.OkAlerta);
$(”.close:visible”).focus();
}</pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Adauto</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-35582</link>
		<dc:creator>Adauto</dc:creator>
		<pubDate>Tue, 16 Jun 2009 16:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-35582</guid>
		<description>I had the same problem. When the exception comes from an Interval Server Error (500), the StackTrace page is shown. I ended up with two solutions. I could either change the Application_Error or get the error through javascript somewhere in the error page. So i decided to go for the second one. By doing this i don&#039;t mess up with the Global.asax.

error: function(result, textStatus, thrownError){                          
                        result.responseText.match(/(.*)/i);                
                        MostraCaixa(&quot;AVISO DE ERRO&quot;, error[1] &#124;&#124; result.responseText, Botoes.OkAlerta);
                        $(&quot;.close:visible&quot;).focus();                        
                    }</description>
		<content:encoded><![CDATA[<p>I had the same problem. When the exception comes from an Interval Server Error (500), the StackTrace page is shown. I ended up with two solutions. I could either change the Application_Error or get the error through javascript somewhere in the error page. So i decided to go for the second one. By doing this i don&#8217;t mess up with the Global.asax.</p>
<p>error: function(result, textStatus, thrownError){<br />
                        result.responseText.match(/(.*)/i);<br />
                        MostraCaixa(&#8220;AVISO DE ERRO&#8221;, error[1] || result.responseText, Botoes.OkAlerta);<br />
                        $(&#8220;.close:visible&#8221;).focus();<br />
                    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-35034</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Tue, 21 Apr 2009 20:22:39 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-35034</guid>
		<description>Not sure if you noticed, but at the bottom of the BlockUI plugin page is a link to another plugin called jGrowl. The nice thing about it is that it has stackable growls in case you have multiple notifications or a click-happy user.

http://stanlemon.net/projects/jgrowl.html</description>
		<content:encoded><![CDATA[<p>Not sure if you noticed, but at the bottom of the BlockUI plugin page is a link to another plugin called jGrowl. The nice thing about it is that it has stackable growls in case you have multiple notifications or a click-happy user.</p>
<p><a href="http://stanlemon.net/projects/jgrowl.html" rel="nofollow">http://stanlemon.net/projects/jgrowl.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Strahl</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-35009</link>
		<dc:creator>Rick Strahl</dc:creator>
		<pubDate>Mon, 20 Apr 2009 08:56:35 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-35009</guid>
		<description>Dave, nice to see this written up. I&#039;ve long cursed the way that jQuery returns error information because there are a number of things that you have to check for.

I think you need a bit more than what you have here though - if there are HTTP level errors you need to possibly manage status codes in addition to an actual error message that the server returns. Casper&#039;s response points at this although I don&#039;t think there&#039;s really any good solution to a 500 level error.

The error handler I use in an $.ajax() wrapper class looks something like this:


error: function(xhr, status) {
   var res = xhr.responseText;
   var err = null;
   if (res &amp;&amp; res.charAt(0) == &#039;{&#039;)
       var err = JSON.parseWithDate(res);
   if (!err) {
       if (xhr.status != 200)
           err = new CallbackException(xhr.status + &quot; &quot; + xhr.statusText);
       else
           err = new CallbackException(&quot;Unknown Error Response&quot;);
       err.detail = res;
   }
   else
       err = new CallbackException(err); // force error to common format

   if (errorHandler)
       errorHandler(err, _I, xhr);
}


Like your code i try first to eval the result, but if that fails then looking at the status code and returning the server&#039;s status code usually is more useful. This isn&#039;t going to be helpful on most 500 type errors, but it will be if you have a 40x error for missing or unauthorized content at least.</description>
		<content:encoded><![CDATA[<p>Dave, nice to see this written up. I&#8217;ve long cursed the way that jQuery returns error information because there are a number of things that you have to check for.</p>
<p>I think you need a bit more than what you have here though &#8211; if there are HTTP level errors you need to possibly manage status codes in addition to an actual error message that the server returns. Casper&#8217;s response points at this although I don&#8217;t think there&#8217;s really any good solution to a 500 level error.</p>
<p>The error handler I use in an $.ajax() wrapper class looks something like this:</p>
<p>error: function(xhr, status) {<br />
   var res = xhr.responseText;<br />
   var err = null;<br />
   if (res &amp;&amp; res.charAt(0) == &#8216;{&#8216;)<br />
       var err = JSON.parseWithDate(res);<br />
   if (!err) {<br />
       if (xhr.status != 200)<br />
           err = new CallbackException(xhr.status + &#8221; &#8221; + xhr.statusText);<br />
       else<br />
           err = new CallbackException(&#8220;Unknown Error Response&#8221;);<br />
       err.detail = res;<br />
   }<br />
   else<br />
       err = new CallbackException(err); // force error to common format</p>
<p>   if (errorHandler)<br />
       errorHandler(err, _I, xhr);<br />
}</p>
<p>Like your code i try first to eval the result, but if that fails then looking at the status code and returning the server&#8217;s status code usually is more useful. This isn&#8217;t going to be helpful on most 500 type errors, but it will be if you have a 40x error for missing or unauthorized content at least.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casper</title>
		<link>http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/#comment-35006</link>
		<dc:creator>Casper</dc:creator>
		<pubDate>Sun, 19 Apr 2009 21:15:13 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=832#comment-35006</guid>
		<description>I know your handling it on the client side but should you do something with it on the code behind?</description>
		<content:encoded><![CDATA[<p>I know your handling it on the client side but should you do something with it on the code behind?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
