zoukankan      html  css  js  c++  java
  • Asp.Net MVC 利用ReflectedActionDescriptor判断Action返回类型

    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");
            }
        }                
    }
    

      

  • 相关阅读:
    完善例题3.2的日期类mydate
    杨辉三角形
    求100以内的素数
    九九乘法表
    实现计算机界面
    完善3.2例题
    杨辉三角法
    素数程序
    九九乘法表
    杨辉三角
  • 原文地址:https://www.cnblogs.com/dreamman/p/4932551.html
Copyright © 2011-2022 走看看