Created
September 30, 2013 17:51
-
-
Save chrishasz/6767497 to your computer and use it in GitHub Desktop.
ASP.NET MVC AjaxOnly Decoration for Controller Actions. Pair with ReturnPartial() for clean, request-controlled partial markup. Usage:
[AjaxOnly]
public ActionResult Action( ... )
{ return PartialView();
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AjaxOnlyAttribute : ActionMethodSelectorAttribute | |
| { | |
| public override Boolean IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) | |
| { | |
| return controllerContext.HttpContext.Request.IsAjaxRequest(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment