Asp.Net MVC 利用ReflectedActionDescriptor判断Action返回类型
2024-08-28 04:45:56
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");
}
}
}
最新文章
- linux c++应用程序内存高或者占用CPU高的解决方案_20161213
- [.NET领域驱动设计实战系列]专题四:前期准备之工作单元模式(Unit Of Work)
- JSP导入EXCEL样式
- CPU绑定操作
- DP总结
- Log4j2常见使用示例及Syslog/Syslog-ng
- 理解 python metaclass使用技巧与应用场景分析
- quartz 的job中获取到applicationContext
- 修正 phpcmsv9 VIP过期日期为1970
- 使用LINQ 對List分頁/區
- Jquery Table 的基本操作
- word的不同章节之间添加不同的页眉
- Android 实现环形进度按钮circular-progress-button
- 生产环境-jvm内存溢出-jprofile问题排查
- Win10个性化设置
- 全方位解读";CPU load average";
- JavaScript设计模式--简单工厂模式例子---XHR工厂
- Akka(31): Http:High-Level-Api,Route rejection handling
- SpringBoot学习笔记
- Windows server 1709(不含UI)模板部署