Skip to content

Instantly share code, notes, and snippets.

@alexbeletsky
Created October 14, 2011 08:57
Show Gist options
  • Save alexbeletsky/1286609 to your computer and use it in GitHub Desktop.
Save alexbeletsky/1286609 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcForDebug2.Infrastructure {
public class ServiceAttribute : ActionFilterAttribute {
public override void OnActionExecuted(ActionExecutedContext filterContext) {
if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest()) {
var viewResult = filterContext.Result as ViewResult;
filterContext.Result = new JsonResult {
Data = viewResult.Model
};
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment