This question is locked. New answers and comments are not allowed.
Hi all,
Whenever I try to do a page, refresh, sort, etc, anything with Ajax, I get Error 500. I sniffed it out in Fiddler and noticed the error was this:
The view 'GetGridModel' or its master was not found or no view engine supports the searched locations. The following locations were searched: etc, etc....
Here's the controller:
And here's the partial view:
Upon the first search, all of the correct data is present.
When I do a sort or refresh, I have verified the method GetGridModel gets called and in fact the data is still sessioned. But the call to
the statement "return View(new GridModel((List<VisitorViewModel>)Session["List"]));" sends out the 500 error in a JavaScript alert box.
For reference, the following script references are on the page:
Additionally, a Telerik MVC Menu is present on the layout page.
Other info:
.NET Framework - 4.0
MVC 3 Razor view engine
Windows Auth - allow all.
Post variables from Fiddler:
Any help is much appreciated.
Whenever I try to do a page, refresh, sort, etc, anything with Ajax, I get Error 500. I sniffed it out in Fiddler and noticed the error was this:
The view 'GetGridModel' or its master was not found or no view engine supports the searched locations. The following locations were searched: etc, etc....
Here's the controller:
public class FrontDeskController : Controller { private readonly IRepository _repository; public FrontDeskController(IRepository repository) { _repository = repository; } public ActionResult Index() { return View(); } [OutputCache(Duration = 0)] public ActionResult Search(VisitorSearchViewModel model) { return DisplayVisitorSearchResults(model); } private ActionResult DisplayVisitorSearchResults(VisitorSearchViewModel model) { var response = GetVisitorSearchResponse(model); if (response.Success) { var visitorModels = response.List.ConvertToVisitorViewModelList(); StoreVisitorInformationInSession(model, visitorModels); return PartialView("_Visitors", visitorModels); } return DisplayErrorView(response); } private ActionResult DisplayErrorView(ResponseBase response) { return Json(new { Success = "false", Title = "Error Retrieving Visitors.", Message = response.Message }); } private ListResponseBase<Visitor> GetVisitorSearchResponse(VisitorSearchViewModel model) { var visitorQuery = new VisitorSearchQuery(_repository); return visitorQuery.Where(model) .PageOfResults(1, int.MaxValue); } private void StoreVisitorInformationInSession(VisitorSearchViewModel model, IEnumerable<VisitorViewModel> visitorModels) { Session["LastFourSSN"] = model.LastFourSSN; Session["LastName"] = model.LastName; Session["List"] = visitorModels.ToList(); } [GridAction] public ActionResult GetGridModel() { return View(new GridModel((List<VisitorViewModel>)Session["List"])); } }And here's the partial view:
@model IEnumerable<CraftTraxNG.Model.ViewModels.VisitorViewModel>@(Html.Telerik().Grid(Model) .Name("Visitors") .DataKeys(dataKeys => dataKeys.Add(o => o.Id)) .Columns (columns => { columns.Bound(o => o.LastFourSSN).Width(50).Filterable(false).Title("SSN"); columns.Bound(o => o.FirstName).Width(100).Filterable(true).Title("First"); columns.Bound(o => o.Middle).Width(50).Filterable(false).Title("Middle"); columns.Bound(o => o.LastName).Width(150).Filterable(false).Title("Last"); columns.Bound(o => o.FormattedPhoneNumber).Width(125).Filterable(true).Title("Primary Phone"); columns.Bound(o => o.FormattedSecondaryPhoneNumber).Width(125).Filterable(true).Title("Secondary Phone"); columns.Bound(o => o.VisitorStatusDisplay).Width(100).Filterable(false).Title("Status"); columns.Bound(o => o.ActionsUrl) .Encoded(false) .ClientTemplate("<#= ActionsUrl #>") .Title("Actions"); }) .DataBinding(dataBinding => dataBinding.Ajax() .Select("GetGridModel", "FrontDesk") .Enabled(true)) .NoRecordsTemplate("No records found") .Scrollable(scrolling => scrolling.Enabled(false)) .Sortable(sorting => sorting.Enabled(true)) .Pageable(paging => paging.Enabled(true)) .Filterable(filtering => filtering.Filters(filters => filters.Add(o => o.FirstName).StartsWith(""))) .Groupable(grouping => grouping.Enabled(false)) .Footer(true))<p> @Html.ActionLink("Create New Visitor", "Create", "Visitor", new { area = "" }, null)</p>Upon the first search, all of the correct data is present.
When I do a sort or refresh, I have verified the method GetGridModel gets called and in fact the data is still sessioned. But the call to
the statement "return View(new GridModel((List<VisitorViewModel>)Session["List"]));" sends out the 500 error in a JavaScript alert box.
For reference, the following script references are on the page:
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.4.min.js" type="text/javascript"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" type="text/javascript"></script><script src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js" type="text/javascript"></script> <script src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.13/jquery-ui.min.js" type="text/javascript"></script><script type="text/javascript" src="/Scripts/2011.3.1115/telerik.common.min.js"></script><script type="text/javascript" src="/Scripts/2011.3.1115/telerik.grid.min.js"></script><script type="text/javascript" src="/Scripts/2011.3.1115/telerik.grid.filtering.min.js"></script><script type="text/javascript" src="/Scripts/2011.3.1115/telerik.menu.min.js"></script>Additionally, a Telerik MVC Menu is present on the layout page.
Other info:
.NET Framework - 4.0
MVC 3 Razor view engine
Windows Auth - allow all.
Post variables from Fiddler:
page=1&size=10&orderBy=LastFourSSN-asc&filter=FirstName~startswith~''
Any help is much appreciated.