Reputation: 350
I have Html.Action method i my layout.cshtml file, which rander search form on every page. In the layout file I have this condition rendering:
@if (dcmodel != null)
{
@Html.Action("SearchForm", "Document", dcmodel)
}
else
{
@Html.Action("SearchForm", "Document")
}
In document controller I have this code:
[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");
}
WhenI logOn to thepage everythink is working... When I change localtime +2 hours and refresh the page I got this error below.
What I´m doing wrong ? Please help! Thnaks!
Unable to cast object of type 'System.Web.Mvc.ViewResult' to type 'System.Web.Mvc.PartialViewResult
at TT.MVCClient.Controllers.DocumentController.SearchForm() in C:\Projects\TT\Controllers\DocumentController.cs:line 138 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.b__10() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
{"Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'."}
Upvotes: 0
Views: 1447