asp.net-mvc – 在内部OnException(ExceptionContext filterContext)中,有什么方法可以恢复传递给POST动作的模型?

情况是这样的:

我找不到获取传递给POST操作方法viewmodel的方法.

[HttpPost]
public ActionResult Edit(SomeCoolModel viewmodel)
{
    // Some Exception happens here during the action execution...
}

在控制器的可覆盖的OnException内:

protected override void OnException(ExceptionContext filterContext)
{
    ...

    filterContext.Result = new ViewResult
    {
        ViewName = filterContext.RouteData.Values["action"].ToString(),TempData = filterContext.Controller.TempData,ViewData = filterContext.Controller.ViewData
    };
}

调试代码时,filterContext.Controller.ViewData为null,因为代码执行时发生了异常,并且未返回任何视图.

无论如何,我看到filterContext.Controller.ViewData.ModelState被填充并具有我需要的所有值,但我没有完整的ViewData => viewmodel对象可用.

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....