すべてのページで検索フォームを表示する、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' にキャストできません
C:\Projects\TT\Controllers\DocumentController.cs:line 138 の TT.MVCClient.Controllers.DocumentController.SearchForm() で lambda_method(Closure , ControllerBase , Object[] ) で 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() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter フィルター、ActionExecutingContext preContext、Func`1 継続)
{"ハンドラー 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper' の子リクエストの実行中にエラーが発生しました。"}