0

我的 layout.cshtml 文件中有 Html.Action 方法,它在每个页面上排列搜索表单。在布局文件中,我有这个条件渲染:

@if (dcmodel != null)
{
    @Html.Action("SearchForm", "Document", dcmodel)
}
else
{
    @Html.Action("SearchForm", "Document")
}

在文档控制器中,我有以下代码:

[ChildActionOnly]
public ActionResult SearchForm()
{
    DocumentSearchModel model = (DocumentSearchModel)TempData["SearchForm"];

    var documentSearchModel = new DocumentSearchModel();

    if (model != null)
    {
        documentSearchModel = model;
    }

    AccessRight accessRight = unitOfWork.PermissionRepository.GetBOPermission(ApplicationViewRight.Document);
    documentSearchModel.ViewModelPermission = new ViewModelPermission(accessRight);

    documentSearchModel.DocumentStatuses = CreateDocumentStatusSelectList();
    documentSearchModel.DocumentTypes = CreateDocumentTypeSelectList();
    documentSearchModel.Storages = CreateStoragesSelectList();

    AccessRight documentAccessRight = unitOfWork.PermissionRepository.GetBOPermission(ApplicationViewRight.ShreddingManagement);

    documentSearchModel.IsShreddingAvailable = documentAccessRight.HasFlag(AccessRight.Create);
    documentSearchModel.IsUserSupervisor = unitOfWork.UserRepository.IsUserSupervisor();

    documentSearchModel.ShowLuceneSearch = unitOfWork.SystemSettingRepository.GetSettingsByCode("UseLuceneSearch").Value.ToLower() == "true";

    return PartialView("_SearchForm", documentSearchModel);
}

    [HttpPost]
    public ActionResult SearchForm(DocumentSearchModel searchModel)
    {

        var dataRequest = this.HttpContext.Request;

        Stream req = Request.InputStream;
        req.Seek(0, System.IO.SeekOrigin.Begin);
        string json = new StreamReader(req).ReadToEnd();

        var input = JsonConvert.DeserializeObject(json);

        TempData["SearchFormJson"] = input;

        TempData["SearchForm"] = searchModel;
        return RedirectToAction("Index");
    }

当我登录到页面时,everythink 正在工作......当我更改本地时间 +2 小时并刷新页面时,我在下面收到此错误。

我做错了什么?请帮忙!谢谢!

无法将“System.Web.Mvc.ViewResult”类型的对象转换为“System.Web.Mvc.PartialViewResult”类型

在 TT.MVCClient.Controllers.DocumentController.SearchForm() 在 C:\Projects\TT\Controllers\DocumentController.cs:line 138 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute( ControllerBase 控制器,Object[] 参数)在 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary`2 参数)在 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext,ActionDescriptor actionDescriptor,IDictionary`2 参数)在System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.b__10() 在 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter 过滤器,ActionExecutingContext preContext,Func`1 延续)

{“执行处理程序'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'的子请求时出错。”}

4

0 回答 0