标签:
System.Web.Mvc.ReflectedActionDescriptor descriptor = filterContext.ActionDescriptor as System.Web.Mvc.ReflectedActionDescriptor; if (descriptor != null) { Type actionType =descriptor.MethodInfo.ReturnType; if (actionType.Equals(typeof(ActionResult))) { if (actionType.IsSubclassOf(typeof(JsonResult))) { Response.Write("JsonResult"); } else if (actionType.IsSubclassOf(typeof(ContentResult))) { Response.Write("ContentResult"); } else { Response.Write("ViewResult"); } } else { if (actionType.Equals(typeof(JsonResult))) { Response.Write("JsonResult"); } else if (actionType.Equals(typeof(ContentResult))) { Response.Write("ContentResult"); } else { Response.Write("ViewResult"); } } }
Asp.Net MVC 利用ReflectedActionDescriptor判断Action返回类型
标签:
原文地址:http://www.cnblogs.com/dreamman/p/4932551.html