<?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: ASP.NET MVC Action Filter &#8211; Ajax Only Attribute</title>
	<atom:link href="http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/feed/" rel="self" type="application/rss+xml" />
	<link>http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/</link>
	<description>Just another developer blog</description>
	<lastBuildDate>Mon, 23 Aug 2010 13:24:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Martin Karlsson</title>
		<link>http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/comment-page-1/#comment-329</link>
		<dc:creator>Martin Karlsson</dc:creator>
		<pubDate>Tue, 02 Feb 2010 13:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://helios.ca/?p=101#comment-329</guid>
		<description>Big warning sign: Some hardware firewalls (e.g. Watchguard) have a feature that silently removes all &quot;non-standard&quot; HTTP headers, including the X-Requested-With header which IsAjaxRequest() checks. So if your AJAX requests suddenly start getting 404&#039;s you now know why!</description>
		<content:encoded><![CDATA[<p>Big warning sign: Some hardware firewalls (e.g. Watchguard) have a feature that silently removes all &#8220;non-standard&#8221; HTTP headers, including the X-Requested-With header which IsAjaxRequest() checks. So if your AJAX requests suddenly start getting 404&#8242;s you now know why!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrexx</title>
		<link>http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/comment-page-1/#comment-19</link>
		<dc:creator>andrexx</dc:creator>
		<pubDate>Fri, 29 May 2009 05:54:49 +0000</pubDate>
		<guid isPermaLink="false">http://helios.ca/?p=101#comment-19</guid>
		<description>Such attribute already exist in MvcFutures assembly - AcceptAjaxAttribute, 
but throw Exception instead 404 error.</description>
		<content:encoded><![CDATA[<p>Such attribute already exist in MvcFutures assembly &#8211; AcceptAjaxAttribute,<br />
but throw Exception instead 404 error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/comment-page-1/#comment-20</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 29 May 2009 02:20:30 +0000</pubDate>
		<guid isPermaLink="false">http://helios.ca/?p=101#comment-20</guid>
		<description>I&#039;m pretty sure we will see such an attribute in a future MVC release, don&#039;t forget we&#039;re still at version 1.0!</description>
		<content:encoded><![CDATA[<p>I&#8217;m pretty sure we will see such an attribute in a future MVC release, don&#8217;t forget we&#8217;re still at version 1.0!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dervalp</title>
		<link>http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/comment-page-1/#comment-15</link>
		<dc:creator>dervalp</dc:creator>
		<pubDate>Fri, 29 May 2009 00:42:47 +0000</pubDate>
		<guid isPermaLink="false">http://helios.ca/?p=101#comment-15</guid>
		<description>I am wondering, is that a normal behavior to put your action &quot;Ajax only&quot; ? For me yes, cause sometime you want to use function only with ajax and if you&#039;re trying the put the url in the browser, sending a 404 is a normal behavior. But if it&#039;s a normal way, why this function is not integrate in the MVC framework ? Is there someone who knows more about this ?</description>
		<content:encoded><![CDATA[<p>I am wondering, is that a normal behavior to put your action &#8220;Ajax only&#8221; ? For me yes, cause sometime you want to use function only with ajax and if you&#8217;re trying the put the url in the browser, sending a 404 is a normal behavior. But if it&#8217;s a normal way, why this function is not integrate in the MVC framework ? Is there someone who knows more about this ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Gunn</title>
		<link>http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/comment-page-1/#comment-13</link>
		<dc:creator>Andrew Gunn</dc:creator>
		<pubDate>Thu, 28 May 2009 16:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://helios.ca/?p=101#comment-13</guid>
		<description>And obviously, the 401 should be 404. Third time lucky!</description>
		<content:encoded><![CDATA[<p>And obviously, the 401 should be 404. Third time lucky!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Gunn</title>
		<link>http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/comment-page-1/#comment-12</link>
		<dc:creator>Andrew Gunn</dc:creator>
		<pubDate>Thu, 28 May 2009 16:25:44 +0000</pubDate>
		<guid isPermaLink="false">http://helios.ca/?p=101#comment-12</guid>
		<description>I mean:

filterContext.Result = new HttpNotFoundResult();</description>
		<content:encoded><![CDATA[<p>I mean:</p>
<p>filterContext.Result = new HttpNotFoundResult();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Gunn</title>
		<link>http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/comment-page-1/#comment-11</link>
		<dc:creator>Andrew Gunn</dc:creator>
		<pubDate>Thu, 28 May 2009 16:25:01 +0000</pubDate>
		<guid isPermaLink="false">http://helios.ca/?p=101#comment-11</guid>
		<description>Good article. Instead of hard-coding the 404 redirect, I&#039;d change the response&#039;s status code and let ASP.NET decide where the user should go:

filterContext.HttpContext.Response.StatusCode = 401;

Alternatively, you could wrap this up in a class that inherits from ActionResult (just like AuthorizeAttribute):

public class HttpNotFoundResult : ActionResult 
{
    public override void ExecuteResult(ControllerContext context) 
    {
        if (context == null) 
        {
            throw new ArgumentNullException(&quot;context&quot;);
        }
                context.HttpContext.Response.StatusCode = 401;
    }
}

...and set the result of the filter context:

filterContext.Result = HttpNotFoundResult;

Hope this helps.</description>
		<content:encoded><![CDATA[<p>Good article. Instead of hard-coding the 404 redirect, I&#8217;d change the response&#8217;s status code and let ASP.NET decide where the user should go:</p>
<p>filterContext.HttpContext.Response.StatusCode = 401;</p>
<p>Alternatively, you could wrap this up in a class that inherits from ActionResult (just like AuthorizeAttribute):</p>
<p>public class HttpNotFoundResult : ActionResult<br />
{<br />
    public override void ExecuteResult(ControllerContext context)<br />
    {<br />
        if (context == null)<br />
        {<br />
            throw new ArgumentNullException(&#8220;context&#8221;);<br />
        }<br />
                context.HttpContext.Response.StatusCode = 401;<br />
    }<br />
}</p>
<p>&#8230;and set the result of the filter context:</p>
<p>filterContext.Result = HttpNotFoundResult;</p>
<p>Hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Nurse</title>
		<link>http://helios.ca/2009/05/27/aspnet-mvc-action-filter-ajax-only-attribute/comment-page-1/#comment-10</link>
		<dc:creator>Andrew Nurse</dc:creator>
		<pubDate>Thu, 28 May 2009 16:00:31 +0000</pubDate>
		<guid isPermaLink="false">http://helios.ca/?p=101#comment-10</guid>
		<description>Cool stuff.  Maybe you could convert it from an Action Filter to an Action Selector though, similar to the AcceptVerbs attribute.  Then, a non ajax result to that method will act like a request to a non-existant action.

(See System.Web.Mvc.ActionMethodSelectorAttribute)</description>
		<content:encoded><![CDATA[<p>Cool stuff.  Maybe you could convert it from an Action Filter to an Action Selector though, similar to the AcceptVerbs attribute.  Then, a non ajax result to that method will act like a request to a non-existant action.</p>
<p>(See System.Web.Mvc.ActionMethodSelectorAttribute)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
