ActionExecutedContext中的ActionDescriptor.ActionParameters

Yai*_*vet 3 c# model-view-controller asp.net-mvc asp.net-mvc-3

班里有什么东西可以作为ActionExecutingContext's ActionDescriptor.ActionParameters财产ActionExecutedContext吗?

我需要在这个阶段调查动作的参数(OnActionExecuted).

bas*_*rat 6

您可以像这样获取参数和值:

// Format the parameters based on our requirements: 
StringBuilder parameters = new StringBuilder();
foreach (var p in filterContext.ActionDescriptor.GetParameters())
{
     if (filterContext.Controller.ValueProvider.GetValue(p.ParameterName) != null)
     {
           parameters.AppendFormat("\r\n\t{0}\t\t:{1}", p.ParameterName,
                       filterContext.Controller.ValueProvider.GetValue(p.ParameterName).AttemptedValue);
     }
}
Run Code Online (Sandbox Code Playgroud)