I have no idea why my action is not being hit. This controller is under an “Area” called api.
$.ajax({
url: defaults.url + (defaults.url.indexOf('?') > 0 ? '&' : '?') + 'r=' + Math.random(),
type: defaults.method,
contentType: 'application/json',
dataType: 'json',
data: defaults.data,
success: function (data) {
public class EventController : Controller
{
[JsonpFilter(Order = 1)]
public JsonResult Register()
{
return new JsonResult
{
JsonRequestBehavior = JsonRequestBehavior.AllowGet,
Data = new ApiRegistrationResponse()
};
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
public class JsonpFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (filterContext == null)
throw new ArgumentNullException("filterContext");
string callback = filterContext.HttpContext.Request.QueryString["callback"];
if (!string.IsNullOrEmpty(callback))
{
var result = filterContext.Result as JsonResult;
if (result == null)
{
throw new InvalidOperationException("JsonpFilterAttribute must be applied only " +
"on controllers and actions that return a JsonResult object.");
}
filterContext.Result = new JsonpResult
{
ContentEncoding = result.ContentEncoding,
ContentType = result.ContentType,
Data = result.Data,
Callback = callback
};
}
}
}
After trial and error I had to exclude the following ninject file
NinjectMVC3.csunder theApp_Startfolder and it started working.