Asp.Net MVC 利用ReflectedActionDescriptor判断Action返回类型
2015-11-03 11:07
141 查看
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 Web API】Authentication with OWIN
- asp.net出现“未将对象引用设置到对象的实例”
- ASP.NET中防止页面多次加载的IsPostBack属性
- 玩转树莓派--网卡配置
- 玩转树莓派--图形界面登陆
- 动态网站开发技术学习1:走进ASP.NET
- php、asp 发起post请求
- ASP.NET : 如何将服务端的多个文件打包下载
- ASP.NET : 如何将服务端的多个文件打包下载
- 【Asp.Net MVC】日常---路由
- asp.net 微信支付源码demo 官方坑爹
- .NET中First,FirstOrDefault,Single,SingleOrDefault的区别是什么
- ASP.NET MVC API 路由生成规则
- Asp.net实现直接在浏览器预览Word、Excel、PDF、Txt文件(附源码)
- ASP.NET如何使用web服务的会话状态
- asp.net中“从客户端中检测到有潜在危险的Request.Form值”错误的解决办法
- ASP.NET Identity Authentication
- AspectJ AOP切面编程(XML配置)
- vs2013下, asp.net mvc5 使用和发布rdlc报表的步骤 ,使用ef来获取数据
- Asp.net中的页面跳转及post数据