The MVC framework: the AcceptAjaxAttribute

There might be some scenarios where you have methods that should only be invoked for AJAX requests. In those cases, you can use the AcceptAjaxAttribute to decorate those methods. This is an ActionMethodSelectorAttribute which overrides the IsValidForRequest and delegates all its work to the Request.IsAjaxRequest extension method.

When you’re not in an AJAX request, the IsAjaxRequest method returns false and you end up getting a 404 for that call. It’s really a simple attribute and you might want to recall how ActionMethodSelectorAttributes interact with the remaining elements of the platform.

And that’s all there is to say about this attribute. Stay tuned for more on the MVC framework.

Advertisements

~ by Luis Abreu on April 8, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: