本文整理汇总了C#中ActionExecutedContext类的典型用法代码示例。如果您正苦于以下问题:C# ActionExecutedContext类的具体用法?C# ActionExecutedContext怎么用?C# ActionExecutedContext使用的例子? 这里精选的类代码示例或许可以为您提供帮助。
示例1: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
ControllerBase controller = filterContext.Controller as ControllerBase;
if (controller != null)
{
string serializedModelState = controller.TempData[Key] as string;
if (!string.IsNullOrEmpty(serializedModelState))
{
IEnumerable
modelStateWrappers = JsonConvert.DeserializeObject>(serializedModelState, new JsonSerializerSettings() { Error = DeserializationErrorHandler });
if (modelStateWrappers != null)
{
ModelStateDictionary modelState = new ModelStateDictionary();
foreach (ModelStateWrapper modelStateWrapper in modelStateWrappers)
{
ModelStateEntry ms = new ModelStateEntry();
ms.ValidationState = modelStateWrapper.ValidationState;
ms.AttemptedValue = modelStateWrapper.Value;
modelState.Add(modelStateWrapper.Key, ms);
}
if (filterContext.Result is ViewResult)
controller.ViewData.ModelState.Merge(modelState);
else controller.TempData.Remove(Key);
}
}
}
base.OnActionExecuted(filterContext);
}
原文链接:http://www.jxszl.com/biancheng/C/556458.html